diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-09-23 12:39:12 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-09-24 12:17:21 +0200 |
commit | 73115ef8730cc2466fdb039acb6b9463bc08808a (patch) | |
tree | 56d29a6fecd7b24c4989f06d918c5d3b9640b132 | |
parent | 2a74fedff0261fb094059c4453eb28e2fcfa9afa (diff) | |
download | php-git-73115ef8730cc2466fdb039acb6b9463bc08808a.tar.gz |
Fixed bug #78589
Don't protect GC while destroying zvals. We may need to add GC
roots during this phase.
-rw-r--r-- | Zend/tests/bug78589.phpt | 19 | ||||
-rw-r--r-- | Zend/zend_gc.c | 2 |
2 files changed, 19 insertions, 2 deletions
diff --git a/Zend/tests/bug78589.phpt b/Zend/tests/bug78589.phpt new file mode 100644 index 0000000000..ac4761f794 --- /dev/null +++ b/Zend/tests/bug78589.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #78589: Memory leak with GC + __destruct() +--FILE-- +<?php + +class Test { + public function __destruct() {} +} + +$test = new Test; +$test->foo = [&$test->foo]; +$ary = [&$ary, $test]; +unset($ary, $test); +gc_collect_cycles(); + +?> +===DONE=== +--EXPECT-- +===DONE=== diff --git a/Zend/zend_gc.c b/Zend/zend_gc.c index b74a8e79b9..8b242c003d 100644 --- a/Zend/zend_gc.c +++ b/Zend/zend_gc.c @@ -1549,7 +1549,6 @@ ZEND_API int zend_gc_collect_cycles(void) /* Destroy zvals */ GC_TRACE("Destroying zvals"); - GC_G(gc_protected) = 1; current = GC_IDX2PTR(GC_FIRST_ROOT); last = GC_IDX2PTR(GC_G(first_unused)); while (current != last) { @@ -1600,7 +1599,6 @@ ZEND_API int zend_gc_collect_cycles(void) GC_TRACE("Collection finished"); GC_G(collected) += count; - GC_G(gc_protected) = 0; GC_G(gc_active) = 0; } |