2015-11-04 01:53:56 +00:00
|
|
|
--TEST--
|
|
|
|
Bug #70805 (Segmentation faults whilst running Drupal 8 test suite)
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
class A {
|
2021-10-11 13:49:27 +00:00
|
|
|
public $b;
|
2015-11-04 01:53:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class B {
|
2021-10-11 13:49:27 +00:00
|
|
|
public $a;
|
2015-11-04 01:53:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class C {
|
2020-02-03 21:52:20 +00:00
|
|
|
public function __destruct() {
|
|
|
|
if (isset($GLOBALS["a"])) {
|
|
|
|
unset($GLOBALS["array"]);
|
|
|
|
unset($GLOBALS["a"]); // this will be called in gc_colloct_roots and put $a into gc roots buf
|
|
|
|
}
|
|
|
|
}
|
2015-11-04 01:53:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$a = new A;
|
|
|
|
$a->b = new B;
|
|
|
|
$a->b->a = $a;
|
|
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
|
|
$c = new A;
|
|
|
|
$array = array($c); //This is used to leave a room for $GLOBALS["a"]
|
|
|
|
unset($c);
|
|
|
|
|
2017-02-03 14:38:03 +00:00
|
|
|
while ($i++ < 9998) {
|
2020-02-03 21:52:20 +00:00
|
|
|
$t = [];
|
|
|
|
$t[] = &$t;
|
|
|
|
unset($t);
|
2015-11-04 01:53:56 +00:00
|
|
|
}
|
|
|
|
$t = [new C];
|
|
|
|
$t[] = &$t;
|
|
|
|
unset($t); // This is used to trigger C::__destruct while doing gc_colloct_roots
|
|
|
|
|
|
|
|
$e = $a;
|
2021-10-02 16:38:55 +00:00
|
|
|
unset($a); // This one cannot be put into roots buf because it's full, thus gc_colloct_roots will be called,
|
2015-11-04 01:53:56 +00:00
|
|
|
// but C::__destructor which is called in gc_colloct_roots will put $a into buf
|
2021-10-02 16:38:55 +00:00
|
|
|
// which will make $a be put into gc roots buf twice
|
2015-11-04 01:53:56 +00:00
|
|
|
var_dump(gc_collect_cycles());
|
|
|
|
?>
|
|
|
|
--EXPECT--
|
|
|
|
int(0)
|