php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27468 foreach in __destruct() causes segfault
Submitted: 2004-03-02 15:46 UTC Modified: 2004-03-03 06:04 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: davojan at mail dot ru Assigned: andi (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2004-03-02 (dev) OS: FreeBSD 4.7-RELEASE
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: davojan at mail dot ru
New email:
PHP Version: OS:

 

 [2004-03-02 15:46 UTC] davojan at mail dot ru
Description:
------------
PHP crashes if foreach for a member of the class called in __destruct(). It doesn't matter - does the member exist or not, is it array or not - result is the same.

Note, that in php5b4 it works fine. Expected result is what I get from it.

Reproduce code:
---------------
<?
class foo {
	function __destruct() {
		foreach ($this->x as $x);
	}
}
new foo();
echo 'OK';
?>

Expected result:
----------------
Warning: Invalid argument supplied for foreach() in /usr/local/www/data-dist/ils/admin/test/static.php on line 4
OK

Actual result:
--------------
Program received signal SIGSEGV, Segmentation fault.
0x28531d8d in zend_objects_free_object_storage (object=0xffffffff) at /usr/ports/distfiles/php5-200403021630/Zend/zend_objects.c:88
88              zend_hash_destroy(object->properties);
(gdb) bt
#0  0x28531d8d in zend_objects_free_object_storage (object=0xffffffff) at /usr/ports/distfiles/php5-200403021630/Zend/zend_objects.c:88
#1  0x28534883 in zend_objects_store_del_ref (zobject=0x80e82f0) at /usr/ports/distfiles/php5-200403021630/Zend/zend_objects_API.c:139
#2  0x28519cde in _zval_dtor (zvalue=0x80e82f0, __zend_filename=0x2859dd20 "/usr/ports/distfiles/php5-200403021630/Zend/zend_execute_API.c", 
    __zend_lineno=358) at /usr/ports/distfiles/php5-200403021630/Zend/zend_variables.c:61
#3  0x2850e5fe in _zval_ptr_dtor (zval_ptr=0xbfbfe120, __zend_filename=0x285a3160 "/usr/ports/distfiles/php5-200403021630/Zend/zend_execute.c", 
    __zend_lineno=3820) at /usr/ports/distfiles/php5-200403021630/Zend/zend_execute_API.c:358
#4  0x28549472 in zend_jmp_no_ctor_handler (execute_data=0xbfbfe168, opline=0x80e85e0, op_array=0x80e80c8)
    at /usr/ports/distfiles/php5-200403021630/Zend/zend_execute.c:3820
#5  0x28541aeb in execute (op_array=0x80e80c8) at /usr/ports/distfiles/php5-200403021630/Zend/zend_execute.c:1339
#6  0x2851c4d0 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/ports/distfiles/php5-200403021630/Zend/zend.c:1041
#7  0x284d23b3 in php_execute_script (primary_file=0xbfbff7b0) at /usr/ports/distfiles/php5-200403021630/main/main.c:1650
#8  0x2854e83e in apache_php_module_main (r=0x81fb038, display_source_mode=0) at /usr/ports/distfiles/php5-200403021630/sapi/apache/sapi_apache.c:54
#9  0x2854f8c8 in send_php (r=0x81fb038, display_source_mode=0, filename=0x81fcb10 "/usr/local/www/data/ils/admin/test/static.php")
    at /usr/ports/distfiles/php5-200403021630/sapi/apache/mod_php5.c:621
#10 0x2854f93b in send_parsed_php (r=0x81fb038) at /usr/ports/distfiles/php5-200403021630/sapi/apache/mod_php5.c:636
#11 0x8053a44 in ap_invoke_handler ()
#12 0x806398d in process_request_internal ()
#13 0x80639ec in ap_process_request ()
#14 0x805cdae in child_main ()
#15 0x805cf40 in make_child ()
#16 0x805d05d in startup_children ()
#17 0x805d5b0 in standalone_main ()
#18 0x805dcab in main ()
#19 0x804fc39 in _start ()

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-02 15:50 UTC] derick@php.net
Verified on Linux, assigning to Andi.
 [2004-03-03 06:04 UTC] pajoye@php.net
This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 15:01:27 2024 UTC