#31721 [NEW]: Wrong memory object management

From: Date: Thu, 27 Jan 2005 12:10:23 +0000
Subject: #31721 [NEW]: Wrong memory object management
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-72929@lists.php.net to get a copy of this message
From: marek dot raida at oskar dot cz Operating system: FreeBSD, Solaris, maybe more... PHP version: 5.0.3 PHP Bug Type: Class/Object related Bug description: Wrong memory object management Description: ------------ When references between more objects, and on of objects is extended from domDocument, has reference to it caller object and use its property in vsprinf, reference to orignal object is destroyed or wrongly managed by garbageCollector... Really confusing -> could be workarounded by calling method of domDocument extended object from outside of referenced object... Reproduce code: --------------- <?php class a { public $a = array(1,2,3); function aa($b){ $b->bb(); } } class b extends domDocument { public $a = NULL; function bb(){ $x = vsprintf('www %s www %s www %s www', $this->a->a) ; } } class x { public $a = null; public $b = null; function __construct() { $this->a = new a(); $this->b = new b(); $this->b->a = $this->a; var_dump('Object a',$this->a, 'Object b',$this->b); $this->a->aa($this->b); var_dump('Object a',$this->a, 'Object b',$this->b); } } $x = new x(); ?> Expected result: ---------------- string(8) "Object a" object(a)#2 (1) { ["a"]=> array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } } string(8) "Object b" object(b)#3 (1) { ["a"]=> object(a)#2 (1) { ["a"]=> array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } } } string(8) "Object a" <<< RIGHT object(a)#2 (1) { ["a"]=> array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } } string(8) "Object b" object(b)#3 (1) { ["a"]=> object(a)#2 (1) { ["a"]=> array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } } } Actual result: -------------- string(8) "Object a" object(a)#2 (1) { ["a"]=> array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } } string(8) "Object b" object(b)#3 (1) { ["a"]=> object(a)#2 (1) { ["a"]=> array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } } } string(8) "Object a" string(8) "Object a" <<< WRONG string(8) "Object b" object(b)#3 (1) { ["a"]=> string(8) "Object a" } -- Edit bug report at http://bugs.php.net/?id=31721&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31721&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31721&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31721&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=31721&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=31721&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=31721&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=31721&r=needscript Try newer version: http://bugs.php.net/fix.php?id=31721&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=31721&r=support Expected behavior: http://bugs.php.net/fix.php?id=31721&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=31721&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=31721&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=31721&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31721&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=31721&r=dst IIS Stability: http://bugs.php.net/fix.php?id=31721&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=31721&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=31721&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=31721&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=31721&r=mysqlcfg

« previous php.bugs (#72929) next »