php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
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
Description:
------------
Calling exit from a user error handler causes an object to be destructed, even if
the object was never constructed.

Test script:
---------------
http://pastebin.com/UeBBj1hK

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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-25 09:48 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2016-07-25 09:48 UTC] cmb@php.net
There doesn't even need to be an error handler involved, see
<https://3v4l.org/cR3nF>. 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] <https://3v4l.org/cR3nF/vld#tabs>
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC