php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65374 Circular references on callbacks can't be resolved by GC
Submitted: 2013-08-02 02:25 UTC Modified: 2017-10-24 04:44 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: bugs dot php dot net at ss dot chernousov dot net Assigned:
Status: Suspended Package: libevent (PECL)
PHP Version: 5.5.1 OS: Gentoo Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bugs dot php dot net at ss dot chernousov dot net
New email:
PHP Version: OS:

 

 [2013-08-02 02:25 UTC] bugs dot php dot net at ss dot chernousov dot net
Description:
------------
If an event's a callback is a method of the object, which holds a reference to 
this event, the object leaks after both the event and the object have been 
nulled.

The test script performs 3 tests:
 - test 1 holds the event as a global variable, and the callback object is 
released as expected;
 - test 2 holds the event as a property of another object, and the callback 
object is released as expected;
 - test 3 holds the event as a property of the same object, which is used for the 
callback, and the object does not get released.

I guess the event leaks too, but I didn't check.

I'm not sure if it's pecl-libevent's or PHP Garbage Collector's bug, but I 
suppose that behaviour is not something one should expect.

The workaround is to explicitly break the reference from the object to the event.


Test script:
---------------
https://gist.github.com/5lava/62629f3d66c9124d2877

Expected result:
----------------
destruct 1
==== THE END of test 1 ====
destruct 3
destruct 2
==== THE END of test 2 ====
destruct 4
==== THE END of test 3 ====


Actual result:
--------------
destruct 1
==== THE END of test 1 ====
destruct 3
destruct 2
==== THE END of test 2 ====
==== THE END of test 3 ====
destruct 4


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-05 19:49 UTC] krakjoe@php.net
-Assigned To: +Assigned To: osmanov
 [2013-08-06 11:55 UTC] osmanov@php.net
-Assigned To: osmanov +Assigned To: tony2001
 [2013-08-06 11:55 UTC] osmanov@php.net
The test script refers to "libevent" extension. Mine is "event". However, "event" 
ext. has similar bug, too.
 [2017-10-24 04:44 UTC] kalle@php.net
-Status: Assigned +Status: Suspended -Assigned To: tony2001 +Assigned To:
 [2017-10-24 04:44 UTC] kalle@php.net
I'm gonna close this as the libevent package on PECL had no had a release for 4 years, and there haven't really been much acitivity since. If development picks back up then this report should be re-opened
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 19:01:30 2024 UTC