xref: /PHP-7.2/Zend/tests/bug63635.phpt (revision 17ccbeec)
1--TEST--
2Bug #63635 (Segfault in gc_collect_cycles)
3--FILE--
4<?php
5class Node {
6	public $parent = NULL;
7	public $childs = array();
8
9	function __construct(Node $parent=NULL) {
10		if ($parent) {
11			$parent->childs[] = $this;
12		}
13		$this->childs[] = $this;
14	}
15
16	function __destruct() {
17		$this->childs = 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--EXPECT--
380
391
402
413
424
435
446
457
468
479
4810
4911
5012
5113
5214
5315
5416
5517
5618
5719
58ok
59