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