From: brad at info-link dot net
Operating system: Linux 2.4.21
PHP version: 4.3.3RC1
PHP Bug Type: Reproducible crash
Bug description: debug_backtrace crashes if $this set to null
Description:
------------
debug_backtrace crashes PHP if called from a class method after $this is
set to null.
Reproduce code:
---------------
The following script illustrates the problem:
<?php
class Foo {
function Bar() {
$__this = $this;
// unset($this);
$this = null;
print_r(debug_backtrace());
$this = $__this;
}
}
$f = new Foo;
$f->Bar();
?>
Strangely, if you use unset instead of assigning $this to null, the crash
does not occur.
Actual result:
--------------
Program received signal SIGSEGV, Segmentation fault.
0x4025ded4 in zif_debug_backtrace (ht=0, return_value=0x81a260c,
this_ptr=0x0, return_value_used=1)
at
/usr/local/php/src/php4-STABLE-200307100130/Zend/zend_builtin_functions.c:1246
1246 class_name =
ptr->object.ptr->value.obj.ce->name;
(gdb) bt
#0 0x4025ded4 in zif_debug_backtrace (ht=0, return_value=0x81a260c,
this_ptr=0x0, return_value_used=1)
at
/usr/local/php/src/php4-STABLE-200307100130/Zend/zend_builtin_functions.c:1246
#1 0x40267f38 in execute (op_array=0x81a21fc) at
/usr/local/php/src/php4-STABLE-200307100130/Zend/zend_execute.c:1616
#2 0x402680f6 in execute (op_array=0x819d434) at
/usr/local/php/src/php4-STABLE-200307100130/Zend/zend_execute.c:1660
#3 0x40255940 in zend_execute_scripts (type=8, retval=0x0, file_count=3)
at /usr/local/php/src/php4-STABLE-200307100130/Zend/zend.c:886
#4 0x4022e83c in php_execute_script (primary_file=0xbffff6e0)
at /usr/local/php/src/php4-STABLE-200307100130/main/main.c:1685
#5 0x4026f34a in apache_php_module_main (r=0x81d9774,
display_source_mode=0)
at
/usr/local/php/src/php4-STABLE-200307100130/sapi/apache/sapi_apache.c:54
#6 0x4026ff32 in send_php (r=0x81d9774, display_source_mode=0,
filename=0x0)
at
/usr/local/php/src/php4-STABLE-200307100130/sapi/apache/mod_php4.c:620
#7 0x4026ff86 in send_parsed_php (r=0x81d9774)
at
/usr/local/php/src/php4-STABLE-200307100130/sapi/apache/mod_php4.c:635
#8 0x0808dd77 in ap_invoke_handler ()
#9 0x080a2e57 in process_request_internal ()
#10 0x080a2eb8 in ap_process_request ()
#11 0x08099cc9 in child_main ()
#12 0x08099e74 in make_child ()
#13 0x08099fe8 in startup_children ()
#14 0x0809a660 in standalone_main ()
#15 0x0809aec3 in main ()
#16 0x42017499 in __libc_start_main () from /lib/i686/libc.so.6
--
Edit bug report at http://bugs.php.net/?id=24573&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=24573&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=24573&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=24573&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=24573&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=24573&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=24573&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=24573&r=support
Expected behavior: http://bugs.php.net/fix.php?id=24573&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=24573&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=24573&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=24573&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24573&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=24573&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=24573&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=24573&r=gnused