Bug #69534 [Asn]: Cycle leaks through declared properties on internal classes
Edit report at https://bugs.php.net/bug.php?id=69534&edit=1
ID: 69534
Updated by: dmitry@php.net
Reported by: nikic@php.net
Summary: Cycle leaks through declared properties on internal
classes
Status: Assigned
Type: Bug
Package: Scripting Engine problem
PHP Version: master-Git-2015-04-26 (Git)
Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
Please review the proposed fix:
https://gist.github.com/dstogov/b53dda976a0b07361b56
Previous Comments:
------------------------------------------------------------------------
[2015-04-26 10:48:55] nikic@php.net
Description:
------------
This code...
<?php
class Node extends SplObjectStorage {
public $prop;
}
$node1 = new Node;
$node2 = new Node;
$node1->prop = $node2;
$node2->prop = $node1;
...will leaks the Node#1, Node#2 cycle.
"SplObjectStorage" can be replaced with any internal class that implements a custom get_gc
handler and uses the usual "custom data table + return std properties" pattern.
The reason is that the GC code no longer checks for INDIRECT elements in the properties hash and
assumes that these elements will also be present in the data table. This is usually not true for
internal objects.
Possible resolutions:
a) Handle INDIRECT in the GC again.
b) Require that the table populated by GC always contains the std properties table. This would
prevent directly returning pointers to internal tables for classes like SplFixedArray, SplHeap or
ArrayObject/Iterator and instead require maintaining gc_data/gc_data_num members like we already do
in some other places. In this variant the default get_gc handler should also be changed to ignore
custom get_properties handlers.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69534&edit=1
Thread (3 messages)