On Wed, Aug 10, 2016 at 12:52 PM, Christoph M. Becker <cmbecke...@gmx.de>
wrote:

> 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.
>

As you correctly deduced, we currently do not support GC for resources.
This would require introducing something akin to the get_gc handler for
resources.

The simplest way to fix ext/xml in particular is probably to migrate it to
use an object instead of a resource.

Nikita

Reply via email to