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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
46 + 1 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 07:01:31 2024 UTC