|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65387 Memleak:Circular references on callbacks can't be resolved by Garbage Collector
Submitted: 2013-08-04 20:14 UTC Modified: 2016-03-26 23:40 UTC
Avg. Score:5.0 ± 0.0
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:1 (25.0%)
From: bugs dot php dot net at ss dot chernousov dot net Assigned:
Status: Verified Package: Scripting Engine problem
PHP Version: 5.5.1 OS: Any
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-08-04 20:14 UTC] bugs dot php dot net at ss dot chernousov dot net
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 

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:

Expected result:
==== NULL ====
==== GC ====
==== THE END ====


==== NULL ====
==== GC ====
==== THE END ====

Actual result:
==== NULL ====
==== GC ====
==== THE END ====


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-26 23:40 UTC]
-Status: Open +Status: Verified
 [2016-03-26 23:40 UTC]
Still leaks, even in PHP 7. dual_it doesn't implement GC handling.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Aug 12 12:01:24 2020 UTC