[php-src] master: Make test more resilient

From: Date: Sat, 10 Oct 2026 17:27:57 +0000
Subject: [php-src] master: Make test more resilient
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142159@lists.php.net to get a copy of this message
Author: Arnaud Le Blanc (arnaud-lb) Committer: Gina Peter Banyard (Girgias) Date: 2026-10-10T18:27:38+01:00 Commit: https://github.com/php/php-src/commit/269eff61d19a066ac442836d6e782c5eb7651e66 Raw diff: https://github.com/php/php-src/commit/269eff61d19a066ac442836d6e782c5eb7651e66.diff Make test more resilient Trigger GC explicitly during lazy object realization instead of relying on buffer size trigger. Changed paths: M Zend/tests/lazy_objects/gh20657-002.phpt Diff: diff --git a/Zend/tests/lazy_objects/gh20657-002.phpt b/Zend/tests/lazy_objects/gh20657-002.phpt index 8aff39d796d6..c9933c3c0eb6 100644 --- a/Zend/tests/lazy_objects/gh20657-002.phpt +++ b/Zend/tests/lazy_objects/gh20657-002.phpt @@ -1,7 +1,5 @@ --TEST-- GH-20657 002: GC during zend_lazy_object_realize() - reset as lazy during realize() ---XFAIL-- -This now throws and I don't understand --FILE-- <?php @@ -16,30 +14,38 @@ class D { } public function __destruct() { global $obj, $reflector; + echo __METHOD__, "\n"; $reflector->resetAsLazyGhost($obj, function () {}); } } +// A cycle, dtor is called on next GC new D(); $reflector = new ReflectionClass(C::class); -for ($i = 0; $i < 10000; $i++) { - $obj = $reflector->newLazyGhost(function ($obj) {}); +$obj = $reflector->newLazyGhost(new class { + function __invoke () {} + function __destruct() { + gc_collect_cycles(); + } +}); - // Add to roots - $obj2 = $obj; - unset($obj2); +// Add to roots +$obj2 = $obj; +unset($obj2); - // Initialize all props to mark object non-lazy. Also create a cycle. - $reflector->getProperty('a')->setRawValueWithoutLazyInitialization($obj, $obj); -} +// Initialize all props to mark object non-lazy. Also create a cycle. +echo "Will realize lazy object\n"; +$reflector->getProperty('a')->setRawValueWithoutLazyInitialization($obj, $obj); +echo "Realized lazy object\n"; var_dump($obj); ?> --EXPECTF-- -object(C)#%d (1) { - ["a"]=> - *RECURSION* +Will realize lazy object +D::__destruct +Realized lazy object +lazy ghost object(C)#%d (0) { }

« previous php.cvs (#142159) next »