com php-src: Add test script for the segfault in gc while run phpspec: Zend/tests/gc_033.phpt
| From: | Xinchen Hui | Date: | Mon, 15 Sep 2014 06:49:34 +0000 |
| Subject: | com php-src: Add test script for the segfault in gc while run phpspec: Zend/tests/gc_033.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-81624@lists.php.net to get a copy of this message | ||
Commit: ae41536c4d55c37c3879e002844f5ffd54d6fedc
Author: Xinchen Hui <laruence@php.net> Mon, 15 Sep 2014 14:49:34 +0800
Parents: 32c46f44a808c792b98b1b222dca43d7a6d4c864
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ae41536c4d55c37c3879e002844f5ffd54d6fedc
Log:
Add test script for the segfault in gc while run phpspec
Changed paths:
A Zend/tests/gc_033.phpt
Diff:
diff --git a/Zend/tests/gc_033.phpt b/Zend/tests/gc_033.phpt
new file mode 100644
index 0000000..bcd1541
--- /dev/null
+++ b/Zend/tests/gc_033.phpt
@@ -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)