mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
A lazy object is marked non-lazy when all its properties are initialized. Before doing so we delete the object info, resulting in a temporarily invalid state. In GH-20657 the GC is triggered at this moment. Fix by deleting the object info _after_ marking it non lazy. Fixes GH-20657 Closes GH-21094
33 lines
553 B
PHP
33 lines
553 B
PHP
--TEST--
|
|
GH-20657: GC during zend_lazy_object_realize()
|
|
--CREDITS--
|
|
vi3tL0u1s
|
|
--FILE--
|
|
<?php
|
|
|
|
class C {
|
|
public $a;
|
|
}
|
|
|
|
$reflector = new ReflectionClass(C::class);
|
|
|
|
for ($i = 0; $i < 10000; $i++) {
|
|
$obj = $reflector->newLazyGhost(function ($obj) {});
|
|
|
|
// 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);
|
|
}
|
|
|
|
var_dump($obj);
|
|
|
|
?>
|
|
--EXPECTF--
|
|
object(C)#%d (1) {
|
|
["a"]=>
|
|
*RECURSION*
|
|
}
|