#28734 [Opn]: Operator = changes structure of self-referencing arrays

From: Date: Sun, 13 Jun 2004 03:04:27 +0000
Subject: #28734 [Opn]: Operator = changes structure of self-referencing arrays
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-60840@lists.php.net to get a copy of this message
ID: 28734 Updated by: curt@php.net Reported By: tomas_matousek at hotmail dot com Status: Open Bug Type: Scripting Engine problem Operating System: WinXP PHP Version: 5.0.0RC2 New Comment: Perhaps this can help track down the problem. php 5.0.0RC3-dev: [snip access array ouptut] [4] => Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => Array *RECURSION* ) ) ) ) /usr/home/curt/cvs/php/php-src/Zend/zend_execute.c(662) : Freeing 0x083C4208 (16 bytes), script=2873.php /usr/home/curt/cvs/php/php-src/Zend/zend_execute.c(3413) : Freeing 0x083C4150 (35 bytes), script=2873.php /usr/home/curt/cvs/php/php-src/Zend/zend_hash.c(377) : Actual location (location was relayed) Last leak repeated 3 times /usr/home/curt/cvs/php/php-src/Zend/zend_execute.c(3382) : Freeing 0x083C410C (16 bytes), script=2873.php Last leak repeated 3 times /usr/home/curt/cvs/php/php-src/Zend/zend_execute.c(3362) : Freeing 0x083C4A6C (32 bytes), script=2873.php /usr/home/curt/cvs/php/php-src/Zend/zend_hash.c(157) : Actual location (location was relayed) Last leak repeated 1 time === Total 11 memory leaks detected === Previous Comments: ------------------------------------------------------------------------ [2004-06-11 19:40:24] imprestavel at gameguru dot com dot br Tested PHP 5.0.0 RC3 and latest build (200406111430) under Windows2000 and had the same problem ------------------------------------------------------------------------ [2004-06-11 09:38:37] tomas_matousek at hotmail dot com Don't know how that is possible in your version of PHP 5.0.0 RC3, but in mine (I'm testing RC3 available on www.php.net not the latest version from CVS) the bug is still there (result is the same as I described in "Actual Result"). ------------------------------------------------------------------------ [2004-06-11 01:43:58] D dot Kingma at jool dot nl Results on RC3: Array ( [0] => 1 [1] => Z [2] => 3 [3] => 4 [4] => Array ( [0] => 1 [1] => Z [2] => 3 [3] => 4 [4] => Array *RECURSION* ) ) Seems as aspected results ------------------------------------------------------------------------ [2004-06-10 20:46:39] tomas_matousek at hotmail dot com Description: ------------ Create an array $b and set some of its item to reference the array itself by =& operator. Then assign this array to some other variable. This assignment (*) makes something wrong in the array $b because if you change $b's items after this assignment the structure of array $b is changed. However, if that assignment (*) doesn't take place the behavior is correct. Reproduce code: --------------- $b = array(1,2,3,4); $b[4] =& $b; // this assignment probably makes changes to $b's structure $c = $b; $b[1] = 'X'; $b[4][1] = 'Y'; $b[4][4][1] = 'Z'; print_r($b); Expected result: ---------------- Array ( [0] => 1 [1] => Z [2] => 3 [3] => 4 [4] => Array *RECURSION* ) Actual result: -------------- Array ( [0] => 1 [1] => X [2] => 3 [3] => 4 [4] => Array ( [0] => 1 [1] => Y [2] => 3 [3] => 4 [4] => Array ( [0] => 1 [1] => Z [2] => 3 [3] => 4 [4] => Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => Array *RECURSION* ) ) ) ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28734&edit=1

« previous php.bugs (#60840) next »