]> granicus.if.org Git - php/commitdiff
Add test script for the segfault in gc while run phpspec
authorXinchen Hui <laruence@php.net>
Mon, 15 Sep 2014 06:49:34 +0000 (14:49 +0800)
committerXinchen Hui <laruence@php.net>
Mon, 15 Sep 2014 06:49:34 +0000 (14:49 +0800)
Zend/tests/gc_033.phpt [new file with mode: 0644]

diff --git a/Zend/tests/gc_033.phpt b/Zend/tests/gc_033.phpt
new file mode 100644 (file)
index 0000000..bcd1541
--- /dev/null
@@ -0,0 +1,28 @@
+--TEST--
+GC 033: Crash in GC while run with phpspec
+--FILE--
+<?php
+$a = new stdClass();
+$a->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)