Bug #74053 [Opn->Csd]: Corrupted class entries on shutdown when a destructor spawns another object

From: Date: Fri, 10 Feb 2017 07:32:44 +0000
Subject: Bug #74053 [Opn->Csd]: Corrupted class entries on shutdown when a destructor spawns another object
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207240@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74053&edit=1

 ID:                 74053
 Updated by:         dmitry@php.net
 Reported by:        jim at commercebyte dot com
 Summary:            Corrupted class entries on shutdown when a
                     destructor spawns another object
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            Class/Object related
 Operating System:   Linux
 PHP Version:        7.1.1
 Block user comment: N
 Private report:     N

 New Comment:

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)


Previous Comments:
------------------------------------------------------------------------
[2017-02-06 23:25:59] 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 />


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=74053&edit=1


Thread (2 messages)

« previous php.bugs (#207240) next »