From ae41536c4d55c37c3879e002844f5ffd54d6fedc Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Mon, 15 Sep 2014 14:49:34 +0800 Subject: [PATCH] Add test script for the segfault in gc while run phpspec --- Zend/tests/gc_033.phpt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Zend/tests/gc_033.phpt diff --git a/Zend/tests/gc_033.phpt b/Zend/tests/gc_033.phpt new file mode 100644 index 0000000000..bcd1541254 --- /dev/null +++ b/Zend/tests/gc_033.phpt @@ -0,0 +1,28 @@ +--TEST-- +GC 033: Crash in GC while run with phpspec +--FILE-- +a = array(); +$a->a[0] = new Stdclass(); +$a->a[0]->a = $a; +$a->a[1] = &$a->a; + +/* remove the self-reference array out of roots */ +gc_collect_cycles(); + +/* do unset */ +unset($a); + +/* let's full the gc roots */ +for ($i=0; $i<9999; $i++) { + $b = range(0, 1); + $b[0] = &$b; + unset($b); +} + +/* then $a will be freed, but $a->a[0] is not. reference to a freed $a */ +var_dump(gc_collect_cycles()); +?> +--EXPECT-- +int(20001) -- 2.50.1