GC issue wrt. to resource <-> object cycles?
| From: | Christoph M. Becker | Date: | Wed, 10 Aug 2016 10:52:41 +0000 |
| Subject: | GC issue wrt. to resource <-> object cycles? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-94997@lists.php.net to get a copy of this message | ||
Hi!
I've tried to fix <https://bugs.php.net/72793>,
and it looks like
there's a general GC issue wrt. to resources referencing objects and
vice versa. Aren't resource ZVALS put in the root buffer?
See <https://3v4l.org/JYIQs>, which demonstrates the
issue better than
the test script in the bug report. A steady increase of allocated
memory can be seen, even though gc_collect_cycles() is called. When
uncommenting
unset($this->parser);, everything is fine (the GC
wouldn't be involved at all in this case).
Wrt. to the PHP 5.6 behavior: this appears fine, but actually it's in
error, because of <https://github.com/php/php-src/commit/72ec2e8f>.
Not
increasing the refcount of parser->object might theoretically lead to
use-after-free scenarios.
--
Christoph M. Becker