ID: 24635
Updated by: [email][/email]
Reported By: eric at cosky dot com
-Status: Open
+Status: Verified
-Bug Type: Reproducible crash
+Bug Type: Zend Engine 2 problem
-Operating System: Windows XP SP1
+Operating System: *
PHP Version: 5CVS-2003-07-13 (dev)
New Comment:

Verified, backtrace as follows:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (runnable)]
_efree (ptr=0x6f697463) at /usr/src/web/php/php5/Zend/zend_alloc.c:257
(gdb) bt
#0 _efree (ptr=0x6f697463) at
#1 0x813e01b in _zval_ptr_dtor (zval_ptr=0x4029afc0) at
#2 0x814b075 in zend_hash_clean (ht=0x4029adbc) at
#3 0x816bb91 in zend_do_fcall_common_helper (execute_data=0xbfffd53c,
at /usr/src/web/php/php5/Zend/zend_execute.c:2673
#4 0x816bd80 in zend_do_fcall_by_name_handler
(execute_data=0xbfffd53c, op_array=0x4029839c)
at /usr/src/web/php/php5/Zend/zend_execute.c:2725
#5 0x815c2c4 in execute (op_array=0x4029839c) at
#6 0x8146b20 in zend_execute_scripts (type=8, retval=0x0,
file_count=3) at /usr/src/web/php/php5/Zend/zend.c:1017
#7 0x811b8d3 in php_execute_script (primary_file=0xbffff898) at
#8 0x8175503 in main (argc=2, argv=0xbffff904) at
#9 0x401b19cb in __libc_start_main (main=0x8174c80 <main>, argc=2,
argv=0xbffff904, init=0x806985c <_init>,
fini=0x8175c14 <_fini>, rtld_fini=0x4000aea0 <_dl_fini>,
at ../sysdeps/generic/libc-start.c:92

Previous Comments:

[2003-07-13 12:53:28] eric at cosky dot com

The following block of code will crash the PHP I installed from (and previous versions).

I've read that I should be using '&new' to gain proper use of
destructors, but it seems reasonable to say that using 'new' shouldn't
cause a server crash. Perhaps a useful thing to do would be to have a
class that has a __destruct() function produce an error if created
without '&new'?

Reproduce code:
class SiteClass {
function __construct() { $this->page = new PageClass(); }
class PageClass {
function Display() {
$section = new SectionClass("PageClass::Display");
class SectionClass {
function __construct($comment) {
$this->Comment = $comment;
function __destruct() {
out($this->Comment); // this line doesn't crash PHP
out("\n<!-- End Section: " . $this->Comment . "-->"); // this line
crashes PHP
function out($code) { return; }
$site = new SiteClass();

Expected result:

Actual result:
System alert for PHP crashing.


Edit this bug report at [url][/url]