Bug #76946 [Com]: Cyclic reference in generator not detected

From: Date: Fri, 28 Sep 2018 16:19:28 +0000
Subject: Bug #76946 [Com]: Cyclic reference in generator not detected
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217272@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76946&edit=1 ID: 76946 Comment by: sam at mousa dot nl Reported by: sam at mousa dot nl Summary: Cyclic reference in generator not detected Status: Open Type: Bug Package: Reproducible crash Operating System: Alpine PHP Version: 7.2.10 Block user comment: N Private report: N New Comment: Running this in phpdbg and then checking the active generators shows they are still active: #1418556: Trapper::getYield(ref=stdClass) at /projects/bug-sample/nodatabase.php:14 #1418558: Trapper::getYield(ref=stdClass) at /projects/bug-sample/nodatabase.php:14 #1418560: Trapper::getYield(ref=stdClass) at /projects/bug-sample/nodatabase.php:14 #1418562: Trapper::getYield(ref=stdClass) at /projects/bug-sample/nodatabase.php:14 Previous Comments: ------------------------------------------------------------------------ [2018-09-28 16:16:29] sam at mousa dot nl Description: ------------ When a specifically structured cyclic reference is created the garbage collector fails to detect it which causes the references to never be freed. This leads to a memory leak. Test script: --------------- https://github.com/SamMousa/yii2-bug-sample/blob/master/nodatabase.php Expected result: ---------------- I'd expect it to never run out of memory; it repeatedly calls a closure that: - Does not access globals - Creates an object that goes out of scope Actual result: -------------- The instances created by the closure never get destroyed, even when explicitly calling gc_collect_cycles. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76946&edit=1

« previous php.bugs (#217272) next »