Development

#2438 (Symfony web debug toolbar segfaults PHP when debugging using xdebug)

You must first sign up to be able to contribute.

Ticket #2438 (closed defect: invalid)

Opened 2 years ago

Last modified 1 year ago

Symfony web debug toolbar segfaults PHP when debugging using xdebug

Reported by: klemen Assigned to: fabien
Priority: minor Milestone:
Component: other Version: 1.2.1
Keywords: xdebug segfault Cc: sean.wedig@gmail.com
Qualification: Unreviewed

Description

The loop where xdebug's action stack is being read crashes if Apache already has an xdebug session enabled.

The situation:

Gentoo Linux 2.6.x Apache 2.0.59 PHP 5.2.4 w/ XDebug 2.0.0 (stable) PHP is configured to run with xdebug extension and debugging server is enabled. The sf_web_debug toolbar is set to on (in any environment). A session is launched within Eclipse PDT using the PHP Debug view, browser opens, but a blank page is presented. Apache logs show PHP segfaulting - stepping through the code takes execution right up to the piece of code that is responsible for populating the xdebug action stack in the web debug toolbar, then PHP dies.

More data to follow.

Attachments

sfVarLogger.class.php (4.3 kB) - added by FX Poster on 12/12/08 04:19:18.
Fixes for sfVarLogger.class.php

Change History

10/23/07 22:44:27 changed by klemen

A suggestion:

Create a new environment-level parameter that makes symfony explicitly ignore xdebug even if the functions are defined. This is an acceptable workaround when debugging using an outside attached debugger like Eclipse PDT.

01/03/08 20:40:35 changed by akvochick

  • summary changed from Symfony web debug toolbar segfaults PHP when debugging using xdebug in Eclipse PDT to Symfony web debug toolbar segfaults PHP when debugging using xdebug.

I don't think it has anything to do with Eclipse. I am getting the same thing just between symfony and xdebug (v2.0.2).

Here is the tail end of an xdebug trace:

1.0857 2039912 +1000 -> sfConfig::get($name = 'sf_web_debug', $default = ???) /usr/local/php5/lib/php/symfony/log/sfLogger/sfWebDebugLogger.class.php:47

>=> TRUE

1.0859 2040032 +120 -> function_exists('xdebug_get_function_stack') /usr/local/php5/lib/php/symfony/log/sfLogger/sfWebDebugLogger.class.php:54

>=> TRUE

1.0860 2039960 -72 -> xdebug_get_function_stack() /usr/local/php5/lib/php/symfony/log/sfLogger/sfWebDebugLogger.class.php:56

** SEGMENTATION FAULT HERE **

I am working around this by commenting out lines 53-75 in sfWebDebugLogger.class.php and adding "$debug_stack = array();" after line 75.

I second the suggestion made by klemen.

01/17/08 00:42:33 changed by jesse

  • version changed from 1.0.8 to 1.1.0.

In symfony 1.1 r6973 I changed line 49 in lib/log/sfWebDebugLogger.class.php to the following:

if (isset($optionsxdebug_logging?) && !isset($_GETXDEBUG_SESSION_START?))

This causes the xdebug_logging option on the sfLogger instance to be set only when a XDEBUG_SESSION_START query variable is supplied. I would have accessed the sfRequest but it is not ready at that point. I'm sure there is a better way to do this but I'll leave that to any senior developers who are interested.

Jesse.

01/17/08 00:53:57 changed by jesse

Sorry, I didn't realize that the wiki formatting would ruin the code. This is the changed line:

if (isset($options![xdebug_logging]) && !isset($_GET![XDEBUG_SESSION_START]))

Also, this causes the xdebug_logging option on the sfLogger instance to be set only when a XDEBUG_SESSION_START query variable is NOT supplied.

02/10/08 05:04:24 changed by shinji

The fix above fails to cover the case when a request is POSTed.

Index: sfWebDebugLogger.class.php
===================================================================
--- sfWebDebugLogger.class.php  (revision 7337)
+++ sfWebDebugLogger.class.php  (working copy)
@@ -51,7 +51,9 @@

     // if we have xdebug, add some stack information
     $debug_stack = array();
-    if (function_exists('xdebug_get_function_stack'))
+    if (function_exists('xdebug_get_function_stack') &&
+       !isset($_GET['XDEBUG_SESSION_START']) &&
+       !isset($_COOKIE['XDEBUG_SESSION']))
     {
       foreach (xdebug_get_function_stack() as $i => $stack)
       {

02/12/08 22:39:34 changed by seanwedig

  • cc set to sean.wedig@gmail.com.

The aggregate $_REQUEST could be used in place of $_GET or $_COOKIE. Any reason not to use it?

I'm also having the same issue, though it appears more likely that this is an issue with XDebug. It's also not 100% of the time, either, as doing a tedious step through the code reveals.

Some calls to the function appear to behave just fine. It's not random, though, and it appears that it does, in fact, always fail at the same moment. In my case, my stack was consistently:

/usr/share/pear/symfony/log/sfLogger/sfWebDebugLogger.class.php.sfWebDebugLogger->log : lineno 56	
/usr/share/pear/symfony/log/sfLogger.class.php.sfLogger->log : lineno 141	
/usr/share/pear/symfony/log/sfLogger.class.php.sfLogger->info : lineno 212	
/usr/share/pear/symfony/controller/sfRouting.class.php.sfRouting->parse : lineno 619	
/usr/share/pear/symfony/request/sfWebRequest.class.php.sfWebRequest->loadParameters : lineno 485	
/usr/share/pear/symfony/request/sfWebRequest.class.php.sfWebRequest->initialize : lineno 333	
cache/applicant/dev/config/config_factories.yml.php.require : lineno 11	
/usr/share/pear/symfony/util/sfContext.class.php.sfContext->initialize : lineno 70	
/usr/share/pear/symfony/util/sfContext.class.php.sfContext::getInstance : lineno 87	
plugins/sfTCPDFPlugin/config/config.php.include : lineno 2	
/usr/share/pear/symfony/config/sfLoader.class.php.sfLoader::loadPluginConfig : lineno 369	
/usr/share/pear/symfony/symfony.php.require : lineno 129	
/usr/share/pear/symfony/util/sfCore.class.php.sfCore::callBootstrap : lineno 56	
/usr/share/pear/symfony/util/sfCore.class.php.sfCore::bootstrap : lineno 34	
apps/applicant/config/config.php.require_once : lineno 8	
web/applicant_dev.php.{main} : lineno 8	

I could get to this exact moment every time with a condition of $message == '{sfRouting} match route [homepage] "/"' on my breakpoint (YMMV with different routing, but I'd wager it's the first routing rule checked).

In my case: PHP 5.2.4, Xdebug v2.0.2 (both installed via yum), and Symfony 1.0.11, on FC7.

02/14/08 11:21:13 changed by shinji

The aggregate $_REQUEST could be used in place of $_GET or $_COOKIE. Any reason not to use it?

The real cause was my ignorance. But I may still prefer to use the latter as I usually stay in the camp where 'explicit is bette than implicit'.

I agree wholely that it's xdebug that needs fixing but even getting fixed version installed may be difficult in a shared hosting environment.

03/07/08 14:51:46 changed by fabien

  • status changed from new to closed.
  • resolution set to fixed.

(In [7763]) fixed web debug toolbar segfaults PHP when debugging using xdebug (closes #2438)

03/07/08 14:52:20 changed by fabien

  • milestone set to 1.0.12.

in r7762

12/12/08 04:17:45 changed by FX Poster

  • status changed from closed to reopened.
  • version changed from 1.1.0 DEV to 1.2.1.
  • resolution deleted.
  • milestone deleted.

I'll open this ticket, because my Apache (and PHP) crashes when I try to debug Symfony application. I use Aptana + xdebug for debugging and there is no $_GET["XDEBUG_SESSION_START"] or $_COOKIE["XDEBUG_SESSION"] variables now. Instead of it, there is a $_SERVER["XDEBUG_CONFIG"] variable:

["XDEBUG_CONFIG"]=>
  string(35) "remote_enable=1 idekey=ECLIPSE_DBGP"

12/12/08 04:19:18 changed by FX Poster

  • attachment sfVarLogger.class.php added.

Fixes for sfVarLogger.class.php

12/12/08 18:25:26 changed by FX Poster

  • status changed from reopened to closed.
  • resolution set to invalid.

03/04/09 11:32:14 changed by m4dm4n

The fix implemented in Symfony did not seem to work using Eclipse PDT (3.3) and Symfony 1.0. I still experience the same issue without fail when I initiate an xdebug session through Eclipse using xdebug < 2.0.4. Neither the xdebug GET variable or cookie is present. It presents as "canary mismatch on efree(), heap overflow" when Suhosin is installed. It has been fixed in xdebug 2.0.4 and upgrading resolves the issue.

It doesn't need fixing since it's an xdebug issue, I just hope this might help someone trying to work out the same problem.

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.