MantisBT

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000022XdebugUsage problems (Wrong Results)public2003-10-15 18:202003-12-01 16:28
Reportersklar 
Assigned To 
PrioritynormalSeveritycrashReproducibilityalways
StatusclosedResolutionopen 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000022: xdebug_get_function_stack() segfaults with collect_params on unless tracing is on
DescriptionWith collect_params on, this script segfaults:

function foo($s) {
    print $s;
    var_dump(xdebug_get_function_stack());
}

foo('bar');

Backtrace:
(gdb) run xdebug-stack-bug.php
Starting program: /usr/local/bin/php xdebug-stack-bug.php
bar
Program received signal SIGSEGV, Segmentation fault.
0x08149b16 in add_index_string (arg=0x0, index=0, str=0x0, duplicate=1)
    at /opt/src/php-4.3.2/Zend/zend_API.c:749
749 ZVAL_STRING(tmp, str, duplicate);
(gdb) bt
#0 0x08149b16 in add_index_string (arg=0x0, index=0, str=0x0, duplicate=1)
    at /opt/src/php-4.3.2/Zend/zend_API.c:749
#1 0x405705e8 in zif_xdebug_get_function_stack (ht=0, return_value=0x8227de4,
    this_ptr=0x0, return_value_used=1)
    at /opt/cvs/cvs.xdebug.org/xdebug/xdebug.c:1259
0000002 0x08140a38 in execute_internal (execute_data_ptr=0x0, return_value_used=1)
    at /opt/src/php-4.3.2/Zend/zend_execute_API.c:42
0000003 0x4056fe22 in xdebug_execute_internal (current_execute_data=0xbfffbaa0,
    return_value_used=1) at /opt/cvs/cvs.xdebug.org/xdebug/xdebug.c:896
0000004 0x08154fb6 in execute (op_array=0x822d790)
    at /opt/src/php-4.3.2/Zend/zend_execute.c:1608
0000005 0x4056fa6e in xdebug_execute (op_array=0x822d790)
    at /opt/cvs/cvs.xdebug.org/xdebug/xdebug.c:864
0000006 0x08154cbb in execute (op_array=0x8228284)
    at /opt/src/php-4.3.2/Zend/zend_execute.c:1650
0000007 0x4056fa6e in xdebug_execute (op_array=0x8228284)
    at /opt/cvs/cvs.xdebug.org/xdebug/xdebug.c:864
0000008 0x081487b5 in zend_execute_scripts (type=8, retval=0x0, file_count=3)
    at /opt/src/php-4.3.2/Zend/zend.c:869
0000009 0x081233eb in php_execute_script (primary_file=0xbfffe850)
    at /opt/src/php-4.3.2/main/main.c:1671
0000010 0x0815a89c in main (argc=2, argv=0xbfffe8d4)
    at /opt/src/php-4.3.2/sapi/cli/php_cli.c:806
0000011 0x420156a4 in __libc_start_main () from /lib/tls/libc.so.6

If I turn tracing on by calling xdebug_start_trace() at the top of the script, then var_dump() correctly shows the stack trace including params. If I turn off collect_params, then the script runs fine whether xdebug_start_trace() is called or not. (The params array element is an empty array in the var_dump() output, as it should be.)
Additional InformationAlthough the stack trace above is from PHP 4.3.2, I get a segfault in the same place with PHP 5
TagsNo tags attached.
Operating SystemRed Hat Linux 9
PHP Version4.3.4-dev
Attached Files

- Relationships

-  Notes
(0000024)
derick (administrator)
2003-10-16 11:05

I could not reproduce this at all with the latest CVS version. Which Xdebug version are you using?
(0000025)
sklar (reporter)
2003-10-16 15:58
edited on: 2003-10-16 15:59

I am using the latest CVS (xdebug.c v1.163). If you like, I can send you my xdebug.so. FWIW, here's the backtrace against PHP 5 (built Oct 14, with --enable-debug)

(gdb) run xdebug-stack-bug.php
Starting program: /opt/cvs/cvs.php.net/php-src/sapi/cli/php xdebug-stack-bug.php
[New Thread 1076471392 (LWP 10749)]
bar
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1076471392 (LWP 10749)]
0x4207a703 in strlen () from /lib/tls/libc.so.6
(gdb) bt
#0 0x4207a703 in strlen () from /lib/tls/libc.so.6
#1 0x081ff473 in add_index_string (arg=0x0, index=1076535304, str=0x0,
    duplicate=1) at /opt/cvs/cvs.php.net/php-src/Zend/zend_API.c:879
0000002 0x404ee830 in zif_xdebug_get_function_stack (ht=0,
    return_value=0x402aa008, this_ptr=0x0, return_value_used=1)
    at /opt/cvs/cvs.xdebug.org/xdebug/xdebug.c:1259
0000003 0x08219eb0 in execute_internal (execute_data_ptr=0xbfffc800,
    return_value_used=1)
    at /opt/cvs/cvs.php.net/php-src/Zend/zend_execute.c:1222
0000004 0x404ee032 in xdebug_execute_internal (current_execute_data=0xbfffc800,
    return_value_used=1) at /opt/cvs/cvs.xdebug.org/xdebug/xdebug.c:896
0000005 0x0821d37f in zend_do_fcall_common_helper (execute_data=0xbfffc800,
    op_array=0x834acb0)
    at /opt/cvs/cvs.php.net/php-src/Zend/zend_execute.c:2549
0000006 0x0821d9ef in zend_do_fcall_handler (execute_data=0xbfffc800,
    op_array=0x834acb0)
    at /opt/cvs/cvs.php.net/php-src/Zend/zend_execute.c:2693
0000007 0x08219fb5 in execute (op_array=0x834acb0)
    at /opt/cvs/cvs.php.net/php-src/Zend/zend_execute.c:1271
0000008 0x404edc7e in xdebug_execute (op_array=0x834acb0)
    at /opt/cvs/cvs.xdebug.org/xdebug/xdebug.c:864
0000009 0x0821d4c5 in zend_do_fcall_common_helper (execute_data=0xbfffcd40,
    op_array=0x402aa70c)
    at /opt/cvs/cvs.php.net/php-src/Zend/zend_execute.c:2576
0000010 0x0821d9ef in zend_do_fcall_handler (execute_data=0xbfffcd40,
    op_array=0x402aa70c)
    at /opt/cvs/cvs.php.net/php-src/Zend/zend_execute.c:2693
0000011 0x08219fb5 in execute (op_array=0x402aa70c)
    at /opt/cvs/cvs.php.net/php-src/Zend/zend_execute.c:1271
0000012 0x404edc7e in xdebug_execute (op_array=0x402aa70c)
    at /opt/cvs/cvs.xdebug.org/xdebug/xdebug.c:864
0000013 0x081fd594 in zend_execute_scripts (type=8, retval=0x0, file_count=3)
    at /opt/cvs/cvs.php.net/php-src/Zend/zend.c:1009
0000014 0x081c460a in php_execute_script (primary_file=0xbffff590)
    at /opt/cvs/cvs.php.net/php-src/main/main.c:1625
0000015 0x082253ee in main (argc=2, argv=0xbffff624)
    at /opt/cvs/cvs.php.net/php-src/sapi/cli/php_cli.c:910
0000016 0x420156a4 in __libc_start_main () from /lib/tls/libc.so.6

edited on: 2003-10-16 15:59
(0000026)
derick (administrator)
2003-10-17 08:59

I still can't reproduce it.. not even valgrind gives any warnings. Can you show me all your xdebug.* settings from phpinfo() ? Perhaps the problem is there somewhere.
(0000033)
sklar (reporter)
2003-10-21 21:42

Here's the xdebug section of phpinfo() output (under PHP5):

xdebug support => enabled
Version => 2.0.0dev
Stacktraces support => enabled
Function nesting protection support => enabled

Supported protocols
DBGp - Common DeBuGger Protocol
GDB - GNU Debugger protocol
PHP3 - PHP 3 Debugger protocol

Directive => Local Value => Master Value
xdebug.allowed_clients => no value => no value
xdebug.auto_profile => Off => Off
xdebug.auto_profile_mode => 0 => 0
xdebug.auto_trace => Off => Off
xdebug.collect_params => On => On
xdebug.default_enable => On => On
xdebug.dump.COOKIE => no value => no value
xdebug.dump.ENV => no value => no value
xdebug.dump.FILES => no value => no value
xdebug.dump.GET => no value => no value
xdebug.dump.POST => no value => no value
xdebug.dump.REQUEST => no value => no value
xdebug.dump.SERVER => no value => no value
xdebug.dump.SESSION => no value => no value
xdebug.dump_once => On => On
xdebug.dump_undefined => Off => Off
xdebug.manual_url => http://www.php.net [^] => http://www.php.net [^]
xdebug.max_nesting_level => 64 => 64
xdebug.output_dir => /tmp => /tmp
xdebug.remote_enable => Off => Off
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => localhost => localhost
xdebug.remote_mode => req => req
xdebug.remote_port => 17869 => 17869

In php-cli.ini (I am running the PHP5 cli binary to do this test), I have:

zend_extension_debug=/opt/php5/lib/php/extensions/debug-non-zts-20020429/xdebug.so
xdebug.collect_params=1

The output of php -m is:

[PHP Modules]
bcmath
calendar
ctype
dba
dom
exif
gd
gettext
mysql
pcntl
pcre
posix
readline
session
shmop
simplexml
sockets
sqlite
standard
sysvsem
sysvshm
tokenizer
xdebug
xml
zlib

[Zend Modules]
Xdebug
(0000069)
derick (administrator)
2003-12-01 16:08

Managed to reproduce it now; fix is on it's way.
(0000070)
derick (administrator)
2003-12-01 16:28

Fixed in CVS; this fix will also be in Xdebug 1.3 when it is released.

- Issue History
Date Modified Username Field Change
2003-10-15 18:20 sklar New Issue
2003-10-16 11:05 derick Note Added: 0000024
2003-10-16 11:05 derick Status new => feedback
2003-10-16 15:58 sklar Note Added: 0000025
2003-10-16 15:59 sklar Note Edited: 0000025
2003-10-17 08:59 derick Note Added: 0000026
2003-10-21 21:42 sklar Note Added: 0000033
2003-12-01 16:08 derick PHP Version 4.3.2 => 4.3.4-dev
2003-12-01 16:08 derick Note Added: 0000069
2003-12-01 16:08 derick Status feedback => confirmed
2003-12-01 16:28 derick Status confirmed => closed
2003-12-01 16:28 derick Note Added: 0000070
2016-07-31 13:36 derick Category Usage problems => Usage problems (Crashes)
2016-07-31 13:38 derick Category Usage problems (Crashes) => Usage problems (Wrong Results)


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker