Bug #69534 [Asn->Csd]: Cycle leaks through declared properties on internal classes

From: Date: Wed, 06 May 2015 18:34:12 +0000
Subject: Bug #69534 [Asn->Csd]: Cycle leaks through declared properties on internal classes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192531@lists.php.net to get a copy of this message
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
+Status:             Closed
 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:

Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=2a9f9860d724296e4853515c04dea3dcb729654d
Log: Fixed bug #69534 (Cycle leaks through declared properties on internal classes)


Previous Comments:
------------------------------------------------------------------------
[2015-05-05 23:11:59] dmitry@php.net

Please review the proposed fix:

https://gist.github.com/dstogov/b53dda976a0b07361b56

------------------------------------------------------------------------
[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)

« previous php.bugs (#192531) next »