Bug #69446 [Asn->Csd]: GC leak relating to removal of nested data after dtors run
| From: | dmitry@php.net | Date: | Tue, 14 Apr 2015 16:54:46 +0000 |
| Subject: | Bug #69446 [Asn->Csd]: GC leak relating to removal of nested data after dtors run | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-192055@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69446&edit=1
ID: 69446
Updated by: dmitry@php.net
Reported by: nikic@php.net
Summary: GC leak relating to removal of nested data after
dtors run
-Status: Assigned
+Status: Closed
Type: Bug
Package: Scripting Engine problem
PHP Version: master-Git-2015-04-14 (Git)
Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=00445ba22dd97988009692e2b35edaeff715f5e1
Log: Fixed bug #69446 (GC leak relating to removal of nested data after dtors run)
Previous Comments:
------------------------------------------------------------------------
[2015-04-14 14:02:48] nikic@php.net
Description:
------------
This issue is only obvious when freeing of the object store is disabled - otherwise the leaks will
be hidden. Here is a patch to disable it: https://gist.github.com/nikic/2ccbc61c407d5e807781
The following script will leak:
<?php
$bar = NULL;
class bad {
public function __destruct() {
global $bar;
$bar = $this;
$bar->y = new stdClass;
}
}
$foo = new stdClass;
$foo->foo = $foo;
$foo->bad = new bad;
$foo->bad->x = new stdClass;
unset($foo);
gc_collect_cycles();
The following script will also leak:
<?php
$bar = NULL;
class bad
{
public $_private = array();
public function __construct()
{
$this->_private[] = 'php';
}
public function __destruct()
{
global $bar;
$bar = $this;
}
}
$foo = new stdclass;
$foo->foo = $foo;
$foo->bad = new bad;
unserialize(serialize($foo));
//unset($foo);
gc_collect_cycles();
var_dump($bar);
I have not been able to figure out how to stop the leak in both cases. The fundamental issue seems
to be that gc_remove_nested_data does not decrement the refcount to compensate the incref that
occurs in gc_collect_roots.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69446&edit=1