php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33165 Calling assert() against local class var in __destruct() causes segfault
Submitted: 2005-05-27 20:24 UTC Modified: 2005-05-28 01:27 UTC
From: dan at wep dot net Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 5.0.4 OS: Fedora Core 3
Private report: No CVE-ID: None
 [2005-05-27 20:24 UTC] dan at wep dot net
Description:
------------
Attempts to access local class variables (defined or not) in a  destructor via an assertion causes a segfault.

Reproduce code:
---------------
<?php
class test {
    private $localValue = 'a string';
    function __destruct() {
        print($this->localValue);             // Works OK
        assert('isset($this->localValue)');   // Segfaults
        assert('isset($this->unknownValue)'); // Segfaults
    }
}
$inst = new test();
?>

Expected result:
----------------
PHP Warning:  assert(): Assertion "isset($this->unknownValue)" failed in test.php on line 7

Actual result:
--------------
Segmentation fault

(gdb) bt
#0  0x081896bb in yy_push_state (new_state=6) at Zend/zend_language_scanner.c:5990
#1  0x08185b0f in lex_scan (zendlval=0xbfffe874) at Zend/zend_language_scanner.c:4021
#2  0x08194e68 in zendlex (zendlval=0xbfffe870) at /usr/src/redhat/BUILD/php-5.0.4/Zend/zend_compile.c:3688
#3  0x08180ab5 in zendparse () at Zend/zend_language_parser.c:2221
#4  0x0818501b in compile_string (source_string=0xbfffe8c0, filename=0x8361b6c "/home/dcox/test.php(6) : assert code")
    at Zend/zend_language_scanner.c:3293
#5  0x0819866f in zend_eval_string (str=0x8362ebc "isset($this->localValue)", retval_ptr=0xbfffe9b0,
    string_name=0x8361b6c "/home/dcox/test.php(6) : assert code") at /usr/src/redhat/BUILD/php-5.0.4/Zend/zend_execute_API.c:994
#6  0x08136410 in zif_assert (ht=1, return_value=0x835014c, this_ptr=0x0, return_value_used=0)
    at /usr/src/redhat/BUILD/php-5.0.4/ext/standard/assert.c:152
#7  0x081cbb0e in zend_do_fcall_common_helper (execute_data=0xbfffeac0, opline=0x83619bc, op_array=0x8362c1c)
    at /usr/src/redhat/BUILD/php-5.0.4/Zend/zend_execute.c:2727
#8  0x081cc2f9 in zend_do_fcall_handler (execute_data=0xbfffeac0, opline=0x83619bc, op_array=0x8362c1c)
    at /usr/src/redhat/BUILD/php-5.0.4/Zend/zend_execute.c:2859
#9  0x081c6cce in execute (op_array=0x8362c1c) at /usr/src/redhat/BUILD/php-5.0.4/Zend/zend_execute.c:1406
#10 0x0819808a in zend_call_function (fci=0xbfffec80, fci_cache=0xbfffec40)
    at /usr/src/redhat/BUILD/php-5.0.4/Zend/zend_execute_API.c:852
#11 0x081b2ba0 in zend_call_method (object_pp=0xbfffed2c, obj_ce=0x8361304, fn_proxy=0x0, function_name=0x820d6db "__destruct",
    function_name_len=10, retval_ptr_ptr=0x0, param_count=0, arg1=0x0, arg2=0x0)
    at /usr/src/redhat/BUILD/php-5.0.4/Zend/zend_interfaces.c:86
#12 0x081b73fe in zend_objects_destroy_object (object=0x8350064, handle=1)
    at /usr/src/redhat/BUILD/php-5.0.4/Zend/zend_objects.c:78
#13 0x081b9982 in zend_objects_store_call_destructors (objects=0x82290a4)
    at /usr/src/redhat/BUILD/php-5.0.4/Zend/zend_objects_API.c:54
#14 0x08196167 in shutdown_executor () at /usr/src/redhat/BUILD/php-5.0.4/Zend/zend_execute_API.c:207
#15 0x081a2715 in zend_deactivate () at /usr/src/redhat/BUILD/php-5.0.4/Zend/zend.c:817
#16 0x081636e1 in php_request_shutdown (dummy=0x0) at /usr/src/redhat/BUILD/php-5.0.4/main/main.c:1216
#17 0x081d1fe5 in main (argc=3, argv=0xbffffa74) at /usr/src/redhat/BUILD/php-5.0.4/sapi/cli/php_cli.c:1049
(gdb)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-28 01:27 UTC] dan at wep dot net
php5-STABLE-200505272037 works as expected.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 19 01:00:03 2025 UTC