summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2016-07-14 22:39:15 +0300
committerDmitry Stogov <dmitry@zend.com>2016-07-14 22:39:15 +0300
commit92e158e3c4cedc6cf4ecad09bddb95aa49b9886c (patch)
tree784e6f726aac081907cd3ef3c95ccac2765aa5d1
parent0f5b5366a6006e255e0d87008ec5e9a5bd5c93c0 (diff)
parent99a5170781d42d3f2b0e042addc005439dadbb53 (diff)
downloadphp-git-92e158e3c4cedc6cf4ecad09bddb95aa49b9886c.tar.gz
Merge branch 'PHP-7.0'
* PHP-7.0: Fixed bug #72286 (Segmentation fault During Garbage Collection)
-rw-r--r--Zend/tests/bug72286.phpt51
1 files changed, 51 insertions, 0 deletions
diff --git a/Zend/tests/bug72286.phpt b/Zend/tests/bug72286.phpt
new file mode 100644
index 0000000000..0f6184d91c
--- /dev/null
+++ b/Zend/tests/bug72286.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Bug #72286 (Segmentation fault During Garbage Collection)
+--FILE--
+<?php
+class SegfaultScenario
+{
+ private $circular_reference;
+ private $object;
+
+ public function __construct()
+ {
+ $this->circular_reference = $this;
+ $this->object = new \stdClass();
+ }
+
+ public function __destruct()
+ {
+ // we try to avoid accessing $this->object by returning early but the object exists
+ if (!$this->object) { // without this expression involving the object, the segfault does not happen
+ var_dump('the object exists');
+ return;
+ }
+
+ var_dump('segfaults here:');
+ // and then access the object (which seemingly has already been garbage collected)
+ var_dump($this->object);
+ var_dump('will not get here');
+ }
+}
+
+class SomeContainer
+{
+ public function run()
+ {
+ new SegfaultScenario();
+ }
+}
+
+$container = new SomeContainer();
+$container->run();
+
+var_dump('we are about to segfault');
+gc_collect_cycles();
+var_dump('will not get here');
+--EXPECTF--
+string(24) "we are about to segfault"
+string(15) "segfaults here:"
+object(stdClass)#%d (0) {
+}
+string(17) "will not get here"
+string(17) "will not get here"