php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74053 Corrupted class entries on shutdown when a destructor spawns another object
Submitted: 2017-02-06 23:25 UTC Modified: -
From: jim at commercebyte dot com Assigned:
Status: Closed Package: Class/Object related
PHP Version: 7.1.1 OS: Linux
Private report: No CVE-ID: None
 [2017-02-06 23:25 UTC] jim at commercebyte dot com
Description:
------------
When a class destructor spawns one or more new object instances - the php shutdown sequence goes wrong in some cases.

Symptoms - "Undefined static property" error messages for properties that are defined in a class, and/or SIGSEGV exception.

Proposed solution:
https://github.com/commercebyte/php-src/commit/9a8a1c9da129a72c9bf8f3392f954a9e5ca317ff

Test script:
---------------
<?
class b {
    function __destruct() {
        echo "b::destruct\n";
    }
}
class a {
    static $b;
    static $new;
    function __destruct() {
        echo "a::destruct\n";
        self::$b = new b;
        $this::$new[] = new a;
    }
}
new a;

Expected result:
----------------
a::destruct
b::destruct
a::destruct
b::destruct
a::destruct
b::destruct
...
(repeats until php runs out of memory)

Actual result:
--------------
a::destruct
b::destruct
a::destruct
b::destruct
a::destruct
<br />
<b>Fatal error</b>:  Access to undeclared static property: a::$b in <b>test.php</b> on line <b>12</b><br />

Patches

class_entry_gone_before_dtor (last revision 2017-02-06 23:26 UTC by jim at commercebyte dot com)

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-02-10 07:32 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c39147d136d67bb3b9e36cdbef7944d831570af4
Log: Fixed bug #74053 (Corrupted class entries on shutdown when a destructor spawns another object). (jim at commercebyte dot com)
 [2017-02-10 07:32 UTC] dmitry@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC