Bug #65387 [Opn->Ver]: Memleak:Circular references on callbacks can't be resolved by Garbage Collector
| From: | nikic@php.net | Date: | Sat, 26 Mar 2016 23:40:59 +0000 |
| Subject: | Bug #65387 [Opn->Ver]: Memleak:Circular references on callbacks can't be resolved by Garbage Collector | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-200132@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65387&edit=1
ID: 65387
Updated by: nikic@php.net
Reported by: bugs dot php dot net at ss dot chernousov dot net
Summary: Memleak:Circular references on callbacks can't be
resolved by Garbage Collector
-Status: Open
+Status: Verified
Type: Bug
Package: Scripting Engine problem
Operating System: Any
PHP Version: 5.5.1
Block user comment: N
Private report: N
New Comment:
Still leaks, even in PHP 7. dual_it doesn't implement GC handling.
Previous Comments:
------------------------------------------------------------------------
[2013-08-04 20:14:37] bugs dot php dot net at ss dot chernousov dot net
Description:
------------
GC fails to resolve the circular reference if object A retains a reference to a
callback in object B and object B retains a reference to object A. Both objects
leak.
Native PHP stuff like SPL iterators with callbacks and Stream callbacks are also
vulnerable to this problem.
This does not apply to userland PHP objects (i.e. objects of classes that were
defined in PHP scripts by a user).
I provided a test script with a number of tests, including SPL iterators with
callbacks, Stream callbacks, as well as 3rd-party extensions like pecl-event,
pecl-ev, pecl-libevent, pecl-eio.
Test script:
---------------
https://gist.github.com/5lava/53aa2e53c7f8c658f045
Expected result:
----------------
==== NULL ====
==== GC ====
Obj::__destruct
==== THE END ====
or
==== NULL ====
Obj::__destruct
==== GC ====
==== THE END ====
Actual result:
--------------
==== NULL ====
==== GC ====
==== THE END ====
Obj::__destruct
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65387&edit=1