xref: /PHP-8.2/Zend/tests/gc_033.phpt (revision f8d79582)
1--TEST--
2GC 033: Crash in GC while run with phpspec
3--INI--
4zend.enable_gc = 1
5--FILE--
6<?php
7$a = new stdClass();
8$a->a = array();
9$a->a[0] = new Stdclass();
10$a->a[0]->a = $a;
11$a->a[1] = &$a->a;
12
13/* remove the self-reference array out of roots */
14gc_collect_cycles();
15
16/* do unset */
17unset($a);
18
19/* let's full the gc roots */
20for ($i=0; $i<9999; $i++) {
21        $b = range(0, 1);
22            $b[0] = &$b;
23            unset($b);
24}
25
26/* then $a will be freed, but $a->a[0] is not. reference to a freed $a */
27var_dump(gc_collect_cycles());
28?>
29--EXPECT--
30int(10002)
31