php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25541 destructor won't be called
Submitted: 2003-09-15 06:35 UTC Modified: 2004-02-04 05:03 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:0 (0.0%)
From: ich at christoph-emonds dot de Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2004-01-27 OS: *
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: ich at christoph-emonds dot de
New email:
PHP Version: OS:

 

 [2003-09-15 06:35 UTC] ich at christoph-emonds dot de
Description:
------------
If you create two objects which contain a reference to the  
other object, none of both __destruct() functions will be 
called.  
  
Configure: './configure' '--with-mysql' '--with-xsl'  
'--with-sqlite' '--enable-sockets' '--with-mysql-sock'  
'--with-gd' '--with-dom' '--with-apxs2=/usr/sbin/apxs2'  
'--with-zlib'   

Reproduce code:
---------------
class A {
	function __construct()	{
		print "Construct A!";
		$this->other = new B( $this );
	}
	function __destruct() {
		print "Destruct A!";
	}
}

class B {
	function __construct( A $obj ) {
		print "Construct B!";
		$this->other = $obj;
	}
	function __destruct() {
		print "Destruct B!";
	}
}
new A();

Expected result:
----------------
Construct A!Construct B!Destruct A!Destruct B! 

Actual result:
--------------
Construct A!Construct B! 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-11 11:02 UTC] sniper@php.net
Construct A!Construct B!
/usr/src/web/php/php5/Zend/zend_hash.c(301) :  Freeing 0x40E4B9F4 (41 bytes), script=t.php
Last leak repeated 1 time
/usr/src/web/php/php5/Zend/zend_execute.c(3095) :  Freeing 0x40E4B7D4 (44 bytes), script=t.php
/usr/src/web/php/php5/Zend/zend_API.c(720) : Actual location (location was relayed)
Last leak repeated 1 time
/usr/src/web/php/php5/Zend/zend_objects.c(88) :  Freeing 0x40E4B790 (12 bytes), script=t.php
Last leak repeated 1 time
/usr/src/web/php/php5/Zend/zend_execute.c(3094) :  Freeing 0x40E4B74C (16 bytes), script=t.php
Last leak repeated 1 time
/usr/src/web/php/php5/Zend/zend_API.c(721) :  Freeing 0x40E4B3EC (32 bytes), script=t.php
/usr/src/web/php/php5/Zend/zend_hash.c(157) : Actual location (location was relayed)
Last leak repeated 1 time
=== Total 10 memory leaks detected ===

 [2004-02-04 05:03 UTC] zeev@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-2025 The PHP Group
All rights reserved.
Last updated: Sat Aug 02 03:00:02 2025 UTC