|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72656 Object destructor called before constructor
Submitted: 2016-07-23 05:29 UTC Modified: 2016-07-25 09:48 UTC
From: joe88 dot ds at gmail dot com Assigned:
Status: Verified Package: Scripting Engine problem
PHP Version: 5.5.38 OS: Windows 7 x64
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: joe88 dot ds at gmail dot com
New email:
PHP Version: OS:


 [2016-07-23 05:29 UTC] joe88 dot ds at gmail dot com
Calling exit from a user error handler causes an object to be destructed, even if
the object was never constructed.

Test script:

Expected result:
The Tree's destructor should never be called.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-25 09:48 UTC]
-Status: Open +Status: Verified
 [2016-07-25 09:48 UTC]
There doesn't even need to be an error handler involved, see
<>. Looking at the opcodes[1] hints at
what's going on behind the scenes: first NEW is executed, and only
after that the arguments for the constructor are evaluated, which,
in this case, cause the script to terminate, without actually
calling the constructor. On shutdown, however, the newly created
object gets properly destroyed by calling its destructor.

In my opinion, this is a bug.

[1] <>
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Aug 04 07:01:24 2021 UTC