|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29098 "new" operator crashes script
Submitted: 2004-07-11 20:35 UTC Modified: 2005-01-22 01:00 UTC
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: antonr at game dot permonline dot ru Assigned:
Status: No Feedback Package: Reproducible crash
PHP Version: 5CVS-2004-07-12 (dev) OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: antonr at game dot permonline dot ru
New email:
PHP Version: OS:


 [2004-07-11 20:35 UTC] antonr at game dot permonline dot ru
When "new" operator appears without "=" operator, it is possibly crashes php

Reproduce code:
  class ParentClass
    { private $child;
      public function __construct($child)
        { echo "ParentClass::__construct()<br>\n";
          $this->child = $child;
      public function __destruct()
        { echo "ParentClass::__destruct()<br>\n";

  class ChildClass
    { private $parent;
      public function setParent($parent)
        { echo "ChildClass::setParent()<br>\n";
          $this->parent = $parent;
      public function __destruct()
        { echo "ChildClass::__destruct()<br>\n";

  new ParentClass(new ChildClass());

Expected result:

and possibly

Actual result:
php crashes


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-11 23:07 UTC]
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
 [2004-07-12 06:58 UTC] 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:
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());
$a = new ParentClass(new ChildClass());

php-cgi.exe and php.exe output same result:


and not crash.
 [2004-07-12 19:47 UTC] antonr at game dot permonline dot ru
Linux Mandrake 10.0: the same behaviour.
 [2004-07-12 19:56 UTC] antonr at game dot permonline dot ru
Bug is independent of OS
 [2004-07-13 16:11 UTC] fixxxer at php5 dot ru
Updating to the latest snapshot seems to fix the problem.
 [2004-07-13 16:40 UTC]
Reproducable under Win2k with latest snapshot, but works ok under Linux.
Valgrind doesn't show any errors about it.
 [2005-01-22 01:00 UTC] php-bugs at lists dot php dot net
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".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 04:01:30 2024 UTC