#28892 [Fbk->NoF]: Object id that's still in use gets reassigned/removing one reference deletes obj
| From: | php-bugs at lists dot php dot net | Date: | Mon, 14 Mar 2005 00:00:10 +0000 |
| Subject: | #28892 [Fbk->NoF]: Object id that's still in use gets reassigned/removing one reference deletes obj | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-75282@lists.php.net to get a copy of this message | ||
ID: 28892
Updated by: php-bugs@lists.php.net
Reported By: paranoid at pcwereld dot be
-Status: Feedback
+Status: No Feedback
Bug Type: Zend Engine 2 problem
Operating System: All
PHP Version: 5.0.0+
New Comment:
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
Previous Comments:
------------------------------------------------------------------------
[2005-03-06 20:32:33] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
[2004-08-14 01:14:23] andrey@php.net
Shorter reproduce script. It shows that removing one reference with
setting the variable holding it to NULL deletes the object thus leaving
one reference handing. In the script of the original reporter this
interferes with a creation of a new object of the class of the
innormally deleted one and the new objects hooks on the nirvana
reference created by the bug.
<?php
new C(new A("FUBAR"));
class A {
public $text;
function __construct($m){
$this->text = $m;
}
}
class C {
public $e;
public $e2;
function __construct($elem){
$this->e = $elem;
$this->e2 = $elem;
$this->e = null;
var_dump($this);
}
}
?>
Output :
object(C)#1 (2) {
["e"]=>
NULL
["e2"]=>
NULL
}
// "e2" has been deleted when $this->e =null; which is not correct
IMHO
Similar example works correctly :
php -r '$a=new stdclass();$b=$a; $a=null; var_dump($a,$b);'
------------------------------------------------------------------------
[2004-06-24 10:38:27] paranoid at pcwereld dot be
When using new C($a = new A()) instead of new C(new A()) the code seems
to work like expected.
------------------------------------------------------------------------
[2004-06-23 12:59:04] paranoid at pcwereld dot be
Description:
------------
PHP reassigns an allready-in-use object id to a newly created object,
after the first object (that loses it's id) was removed from an array,
but was still referenced in another object.
Reproduce code:
---------------
http://users.pandora.be/paranet/poc.html
Expected result:
----------------
I expected that object C would still contain a reference to the first A
object (A-1) i created, ...
Actual result:
--------------
(see comments in code for the actual output)
... instead A-1 was overwritten with a second A object (A-2) i created,
that (!!!!!) used the same object id as the first A object.
PHP seems to be missing the fact that A-1 is still referenced inside
the C object, and thus assigns the object id A-1 was using to A-2
Removing the part marked "important" in list_remove results in a normal
behaviour, eg. C refers to A-1, not A-2. And A-2 doesn't get the same
object id as A-1. The bug is probably somewhere in the code that
removes an object from an array.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28892&edit=1