xref: /PHP-8.0/Zend/tests/bug63635.phpt (revision 853b7945)
1--TEST--
2Bug #63635 (Segfault in gc_collect_cycles)
3--FILE--
4<?php
5class Node {
6    public $parent = NULL;
7    public $children = array();
8
9    function __construct(Node $parent=NULL) {
10        if ($parent) {
11            $parent->children[] = $this;
12        }
13        $this->children[] = $this;
14    }
15
16    function __destruct() {
17        $this->children = NULL;
18    }
19}
20
21define("MAX", 16);
22
23for ($n = 0; $n < 20; $n++) {
24    $top = new Node();
25    for ($i=0 ; $i<MAX ; $i++) {
26        $ci = new Node($top);
27        for ($j=0 ; $j<MAX ; $j++) {
28            $cj = new Node($ci);
29            for ($k=0 ; $k<MAX ; $k++) {
30                $ck = new Node($cj);
31            }
32        }
33    }
34    echo "$n\n";
35}
36echo "ok\n";
37?>
38--EXPECT--
390
401
412
423
434
445
456
467
478
489
4910
5011
5112
5213
5314
5415
5516
5617
5718
5819
59ok
60