xref: /PHP-8.0/Zend/tests/bug69446.phpt (revision 7aacc705)
1--TEST--
2Bug #69446 (GC leak relating to removal of nested data after dtors run)
3--INI--
4zend.enable_gc = 1
5--FILE--
6<?php
7$bar = NULL;
8class bad {
9    public function __destruct() {
10        global $bar;
11        $bar = $this;
12        $bar->y = new stdClass;
13    }
14}
15
16$foo = new stdClass;
17$foo->foo = $foo;
18$foo->bad = new bad;
19$foo->bad->x = new stdClass;
20
21unset($foo);
22gc_collect_cycles();
23var_dump($bar);
24?>
25--EXPECT--
26object(bad)#2 (2) {
27  ["x"]=>
28  object(stdClass)#3 (0) {
29  }
30  ["y"]=>
31  object(stdClass)#4 (0) {
32  }
33}
34