|  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: -
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
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
If I first assigned value by value, the result is correct. But if I first 
assigned value by references, result is very strange. 

$array2 = array('ooo');
$array2[] =& $array2;
$array2[] = $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, 

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:
$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 />

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


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 24 04:01:31 2024 UTC