php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24573 debug_backtrace crashes if $this set to null
Submitted: 2003-07-09 22:23 UTC Modified: 2003-07-18 07:19 UTC
From: brad at info-link dot net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.3.3RC1 OS: Linux 2.4.21
Private report: No CVE-ID:
 [2003-07-09 22:23 UTC] brad at info-link dot net
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-18 07:19 UTC] sniper@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 [2004-08-10 15:08 UTC] skylark44 at mynet dot com

 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 16 07:02:02 2014 UTC