#36006 [Asn]: Problem with $this in __destruct()
| From: | php_nospam at ramihyn dot sytes dot net | Date: | Sat, 14 Jan 2006 00:34:06 +0000 |
| Subject: | #36006 [Asn]: Problem with $this in __destruct() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-91887@lists.php.net to get a copy of this message | ||
ID: 36006
User updated by: php_nospam at ramihyn dot sytes dot net
Reported By: php_nospam at ramihyn dot sytes dot net
Status: Assigned
Bug Type: Scripting Engine problem
Operating System: Windows, Debian Sarge
PHP Version: 5.1.2
Assigned To: dmitry
New Comment:
Verified this bug with all 5.0.x and 5.1.x versions on both OS (except
5.1.2 on Debian; currently compiling for a backtrace)
Previous Comments:
------------------------------------------------------------------------
[2006-01-14 01:19:08] tony2001@php.net
Dmitry, please check it out.
Looks like a chicken-and-egg problem to me.
------------------------------------------------------------------------
[2006-01-14 01:13:32] php_nospam at ramihyn dot sytes dot net
Description:
------------
segfault caused by setting properties to null in __destruct()
Reproduce code:
---------------
<?php
class Person {
public $dad;
public function __destruct() {
$this->dad = null; /* no segfault if this is commented out */
}
}
class Dad extends Person {
public $son;
public function __construct() {
$this->son = new Person;
$this->son->dad = $this; /* no segfault if this is commented out */
}
public function __destruct() {
$this->son = null;
parent::__destruct(); /* segfault here */
}
}
$o = new Dad;
unset($o);
?>
Expected result:
----------------
No segfault
Actual result:
--------------
PHP crashes due to a segfault (crashes apache worker thread when
running as apache module)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36006&edit=1