php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54116 GC process circle references
Submitted: 2011-02-28 11:02 UTC Modified: -
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:2 (66.7%)
From: lgg860911 at yahoo dot com dot cn Assigned:
Status: Open Package: Variables related
PHP Version: 5.3.5 OS: ubuntu linux 10.10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lgg860911 at yahoo dot com dot cn
New email:
PHP Version: OS:

 

 [2011-02-28 11:02 UTC] lgg860911 at yahoo dot com dot cn
Description:
------------
If I first assigned value by value, the result is correct. But if I first 
assigned value by references, result is very strange. 

<?php
$array2 = array('ooo');
$array2[] =& $array2;
$array2[] = $array2;
xdebug_debug_zval(array2);
?>
Above script will get bellow output:
array2: (refcount=3, is_ref=1)=array (0 => (refcount=2, is_ref=0)='ooo', 1 => 
(refcount=3, is_ref=1)=..., 2 => (refcount=2, is_ref=0)=array (0 => (refcount=2, 
is_ref=0)='ooo', 1 => (refcount=3, is_ref=1)=..., 2 => (refcount=2, 
is_ref=0)=...)) 

but when run at "$array2[] = $array2", $array2[2] now haven't any value, but 
after assigned, it have a circle reference to $array2[2]...
I think this is a bug...
If this is't a bug, could tell me why?

Test script:
---------------
<?php
$array1 = array('ooo');
$array1[] = $array1;
$array1[] =& $array1;
$array2 = array('ooo');
$array2[] =& $array2;
$array2[] = $array2;

print "<h1>Initial datas</h1>";
print <<< 'nowdoc'
$array1 = array('ooo');<br />
$array1[] = $array1;<br />
$array1[] =& $array1;<br />
$array2 = array('ooo');<br />
$array2[] =& $array2;<br />
$array2[] = $array2;<br />
nowdoc;

print "<h1>xdebug_debug_zval result:</h1>";
xdebug_debug_zval("array1"); print "<br />";
xdebug_debug_zval("array2"); print "<br />";
?>


Patches

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC