1--TEST-- 2Bug #70805 (Segmentation faults whilst running Drupal 8 test suite) 3--FILE-- 4<?php 5class A { 6 public $b; 7} 8 9class B { 10 public $a; 11} 12 13class C { 14 public function __destruct() { 15 if (isset($GLOBALS["a"])) { 16 unset($GLOBALS["array"]); 17 unset($GLOBALS["a"]); // this will be called in gc_collect_roots and put $a into gc roots buf 18 } 19 } 20} 21 22$a = new A; 23$a->b = new B; 24$a->b->a = $a; 25 26$i = 0; 27 28$c = new A; 29$array = array($c); //This is used to leave a room for $GLOBALS["a"] 30unset($c); 31 32while ($i++ < 9998) { 33 $t = []; 34 $t[] = &$t; 35 unset($t); 36} 37$t = [new C]; 38$t[] = &$t; 39unset($t); // This is used to trigger C::__destruct while doing gc_collect_roots 40 41$e = $a; 42unset($a); // This one cannot be put into roots buf because it's full, thus gc_collect_roots will be called, 43 // but C::__destructor which is called in gc_collect_roots will put $a into buf 44 // which will make $a be put into gc roots buf twice 45var_dump(gc_collect_cycles()); 46?> 47--EXPECT-- 48int(0) 49