[php-src] Issue #13683: Ref counting object release is not working if cycle is broken in destructor during GC run

From: Date: Tue, 12 Mar 2024 10:26:25 +0000
Subject: [php-src] Issue #13683: Ref counting object release is not working if cycle is broken in destructor during GC run
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246566@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/13683 Author: mvorisek ### Description repro: https://3v4l.org/USrWu see UPDATE below It seems the GC can be improved. Currently, when a cycle is broken during GC run, a 2nd run of GC is needed to really release the object. https://github.com/php/php-src/commit/b58d74547f "solves this issue" since PHP 8.2+, but is that the most efficient solution for everything? If a cycle (all cycles/references to an object) is explicitly broken during GC, is there anything againts releasing that object by standard refcounting? Resulted in this output: ``` d gc bool(true) <- notice object is kept alive after the destructor has broken the cycle (and refcount dropped to 0) gc rerun bool(false) bool(false) done ``` But I expected this output instead: ``` d gc bool(false) gc rerun bool(false) bool(false) done ``` UPDATE: Based on https://3v4l.org/ir6bU I would call this a bug as 2nd WeakReference::get() call is expected to always give the same result if no GC is run in between the calls. ### PHP Version any (tested PHP 7.4, 8.3) ### Operating System any

« previous php.bugs (#246566) next »