[xdebug-dev] xdebug xdebug/xdebug.c xdebug/tests/bug00241.phpt - Fixed bug #241: Crash in xdebug_get_function_stack().

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Sat, 17 Feb 2007 23:23:38 +0100

Date: Sat Feb 17 23:23:38 CET 2007
User: Derick Rethans
Directory: xdebug

Log Message:
[0.50]
- Fixed bug #241: Crash in xdebug_get_function_stack().

Modified files:
           xdebug/xdebug.c (version: 1.371)
Added files:
           xdebug/tests/bug00241.phpt (new version: 1.1)

[FILE: /xdebug/xdebug.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.370
retrieving revision 1.371
diff -u -r1.370 -r1.371
--- xdebug/xdebug.c:1.370 Sun Jan 14 16:55:43 2007 GMT
+++ xdebug/xdebug.c Sat Feb 17 21:23:38 2007 GMT
@@ -316,11 +316,11 @@
 #if ZEND_EXTENSION_API_NO < 90000000
         STD_PHP_INI_ENTRY("xdebug.var_display_max_children", "128", PHP_INI_ALL, OnUpdateInt, display_max_children, zend_xdebug_globals, xdebug_globals)
         STD_PHP_INI_ENTRY("xdebug.var_display_max_data", "512", PHP_INI_ALL, OnUpdateInt, display_max_data, zend_xdebug_globals, xdebug_globals)
- STD_PHP_INI_ENTRY("xdebug.var_display_max_depth", "2", PHP_INI_ALL, OnUpdateInt, display_max_depth, zend_xdebug_globals, xdebug_globals)
+ STD_PHP_INI_ENTRY("xdebug.var_display_max_depth", "3", PHP_INI_ALL, OnUpdateInt, display_max_depth, zend_xdebug_globals, xdebug_globals)
 #else
         STD_PHP_INI_ENTRY("xdebug.var_display_max_children", "128", PHP_INI_ALL, OnUpdateLong, display_max_children, zend_xdebug_globals, xdebug_globals)
         STD_PHP_INI_ENTRY("xdebug.var_display_max_data", "512", PHP_INI_ALL, OnUpdateLong, display_max_data, zend_xdebug_globals, xdebug_globals)
- STD_PHP_INI_ENTRY("xdebug.var_display_max_depth", "2", PHP_INI_ALL, OnUpdateLong, display_max_depth, zend_xdebug_globals, xdebug_globals)
+ STD_PHP_INI_ENTRY("xdebug.var_display_max_depth", "3", PHP_INI_ALL, OnUpdateLong, display_max_depth, zend_xdebug_globals, xdebug_globals)
 #endif
 PHP_INI_END()
 
@@ -2286,7 +2286,15 @@
                 MAKE_STD_ZVAL(params);
                 array_init(params);
                 for (j = 0; j < i->varc; j++) {
- argument = xdebug_get_zval_value(i->var[j].addr, 0, NULL);
+ if (i->var[j].addr) {
+ argument = xdebug_get_zval_value(i->var[j].addr, 0, NULL);
+ } else {
+ zval *tmp_zval;
+ MAKE_STD_ZVAL(tmp_zval);
+ argument = xdebug_get_zval_value(tmp_zval, 0, NULL);
+ zval_dtor(tmp_zval);
+ FREE_ZVAL(tmp_zval);
+ }
                         if (i->var[j].name) {
                                 add_assoc_string_ex(params, i->var[j].name, strlen(i->var[j].name) + 1, argument, 1);
                         } else {

[FILE: /xdebug/tests/bug00241.phpt]

--TEST--
Test for bug #241: Crash in xdebug_get_function_stack().
--SKIPIF--
<?php if (!extension_loaded("xdebug")) print "skip"; ?>
<?php if(version_compare(zend_version(), "2.0.0-dev", '<')) echo "skip Zend Engine 2 needed\n"; ?>
--INI--
xdebug.enable=1
xdebug.auto_trace=0
xdebug.collect_params=1
xdebug.collect_vars=1
xdebug.auto_profile=0
xdebug.profiler_enable=0
--FILE--
<?php
function error_handler($errno, $string, $file, $line, $context)
{
        $entry = Error_Class::newError();
}

class Error_Class
{
        public static function newError($errno = false)
        {
                return new Error_Entry(false, $errno);
        }

        public static function getBT()
        {
                $tmp = xdebug_get_function_stack();
                var_dump($tmp);
        }

}

class Error_Entry
{
        public function __construct($base, $errno)
        {
                Error_Class::getBT();
        }
}

set_error_handler('error_handler');

$tmp = explode('/', trim($_SERVER['FOO'], '/'));
echo "The End\n";
?>
--EXPECTF--
array(5) {
  [0]=>
  array(4) {
    ["function"]=>
    string(6) "{main}"
    ["file"]=>
    string(%d) "%sbug00241.php"
    ["line"]=>
    int(0)
    ["params"]=>
    array(0) {
    }
  }
  [1]=>
  array(4) {
    ["function"]=>
    string(13) "error_handler"
    ["file"]=>
    string(%d) "%sbug00241.php"
    ["line"]=>
    int(0)
    ["params"]=>
    array(5) {
      ["errno"]=>
      string(1) "8"
      ["string"]=>
      string(23) "'Undefined index: FOO'"
      ["file"]=>
      string(%d) "'%sbug00241.php'"
      ["line"]=>
      string(2) "32"
      ["context"]=>
      string(98) "array ('GLOBALS' => ..., '_ENV' => array ('SSH_AGENT_PID' => '3466', 'TERM' => 'xterm', ...), ...)"
    }
  }
  [2]=>
  array(5) {
    ["function"]=>
    string(8) "newError"
    ["class"]=>
    string(11) "Error_Class"
    ["file"]=>
    string(%d) "%sbug00241.php"
    ["line"]=>
    int(4)
    ["params"]=>
    array(1) {
      ["errno"]=>
      string(4) "NULL"
    }
  }
  [3]=>
  array(5) {
    ["function"]=>
    string(11) "__construct"
    ["class"]=>
    string(11) "Error_Entry"
    ["file"]=>
    string(%d) "%sbug00241.php"
    ["line"]=>
    int(11)
    ["params"]=>
    array(2) {
      ["base"]=>
      string(5) "FALSE"
      ["errno"]=>
      string(5) "FALSE"
    }
  }
  [4]=>
  array(5) {
    ["function"]=>
    string(5) "getBT"
    ["class"]=>
    string(11) "Error_Class"
    ["file"]=>
    string(%d) "%sbug00241.php"
    ["line"]=>
    int(26)
    ["params"]=>
    array(0) {
    }
  }
}
The End
Received on Sat Feb 17 2007 - 23:23:40 GMT

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST