#36006 [Opn->Asn]: Problem with $this in __destruct()

From: Date: Sat, 14 Jan 2006 00:19:09 +0000
Subject: #36006 [Opn->Asn]: Problem with $this in __destruct()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-91885@lists.php.net to get a copy of this message
ID: 36006 Updated by: tony2001@php.net Reported By: php_nospam at ramihyn dot sytes dot net -Status: Open +Status: Assigned Bug Type: Scripting Engine problem Operating System: Windows, Debian Sarge PHP Version: 5.1.2 -Assigned To: +Assigned To: dmitry New Comment: Dmitry, please check it out. Looks like a chicken-and-egg problem to me. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#91885) next »