Bug #69446 [NEW]: GC leak relating to removal of nested data after dtors run
| From: | nikic@php.net | Date: | Tue, 14 Apr 2015 14:02:49 +0000 |
| Subject: | Bug #69446 [NEW]: GC leak relating to removal of nested data after dtors run | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-192040@lists.php.net to get a copy of this message | ||
From: nikic
Operating system:
PHP version: master-Git-2015-04-14 (Git)
Package: Scripting Engine problem
Bug Type: Bug
Bug description:GC leak relating to removal of nested data after dtors run
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 bug report at https://bugs.php.net/bug.php?id=69446&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69446&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69446&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69446&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69446&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69446&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69446&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69446&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69446&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69446&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69446&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69446&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69446&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69446&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69446&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69446&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69446&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69446&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69446&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69446&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69446&r=mysqlcfg