#31721 [Opn]: Wrong memory object management
| From: | marek dot raida at oskar dot cz | Date: | Thu, 27 Jan 2005 12:14:09 +0000 |
| Subject: | #31721 [Opn]: Wrong memory object management | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-72930@lists.php.net to get a copy of this message | ||
ID: 31721
User updated by: marek dot raida at oskar dot cz
Reported By: marek dot raida at oskar dot cz
Status: Open
Bug Type: Class/Object related
Operating System: FreeBSD, Solaris, maybe more...
PHP Version: 5.0.3
New Comment:
I forgot to mention that in PHP 5.0.2 everything works correctly...
Previous Comments:
------------------------------------------------------------------------
[2005-01-27 13:10:22] marek dot raida at oskar dot cz
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 this bug report at http://bugs.php.net/?id=31721&edit=1