ID: 29098
User updated by: antonr at game dot permonline dot ru
Reported By: antonr at game dot permonline dot ru
Status: Open
Bug Type: Reproducible crash
Operating System: WinXP Pro SP1
PHP Version: 5CVS-2004-07-12 (dev)
New Comment:
Linux Mandrake 10.0: the same behaviour.
Previous Comments:
------------------------------------------------------------------------
[2004-07-12 06:58:58] antonr at game dot permonline dot ru
On last snap Jul 12, 2004 02:30 GMT
php-cgi.exe outputs nothing to browser and crushes.
php.exe outputs:
ChildClass::__destruct()<br>
ParentClass::__construct()<br>
and then crushes.
One else bug: why ChildClass::__destruct are called before
ParentClass::__construct? You see, the reference on ChildClass instance
must be passed to ParentClass::__construct.
If I change the line
new ParentClass(new ChildClass());
to
$a = new ParentClass(new ChildClass());
php-cgi.exe and php.exe output same result:
ParentClass::__construct()<br>
ChildClass::setParent()<br>
ParentClass::__destruct()<br>
ChildClass::__destruct()<br>
and not crash.
------------------------------------------------------------------------
[2004-07-11 23:07:32] [EMAIL PROTECTED]
How do you mean possibly? My output with script given:
PHP Fatal error: Call to a member function setParent() on a non-object
in test.php on line 7
ParentClass::__destruct()<br>
------------------------------------------------------------------------
[2004-07-11 20:35:32] antonr at game dot permonline dot ru
Description:
------------
When "new" operator appears without "=" operator, it is possibly
crashes php
Reproduce code:
---------------
<?php
class ParentClass
{ private $child;
public function __construct($child)
{ echo "ParentClass::__construct()<br>\n";
$this->child = $child;
$child->setParent($this);
}
public function __destruct()
{ echo "ParentClass::__destruct()<br>\n";
unset($this->child);
}
}
class ChildClass
{ private $parent;
public function setParent($parent)
{ echo "ChildClass::setParent()<br>\n";
$this->parent = $parent;
}
public function __destruct()
{ echo "ChildClass::__destruct()<br>\n";
unset($this->parent);
}
}
new ParentClass(new ChildClass());
?>
Expected result:
----------------
ParentClass::__construct()
ChildClass::setParent()
and possibly
ChildClass::__destruct()
ParentClass::__destruct()
Actual result:
--------------
php crashes
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29098&edit=1