Bug #74053 [NEW]: Corrupted class entries on shutdown when a destructor spawns another object

From: Date: Mon, 06 Feb 2017 23:26:05 +0000
Subject: Bug #74053 [NEW]: Corrupted class entries on shutdown when a destructor spawns another object
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207206@lists.php.net to get a copy of this message
From:             jim at commercebyte dot com
Operating system: Linux
PHP version:      7.1.1
Package:          Class/Object related
Bug Type:         Bug
Bug description:Corrupted class entries on shutdown when a destructor spawns another object

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 bug report at https://bugs.php.net/bug.php?id=74053&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=74053&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=74053&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=74053&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=74053&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=74053&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=74053&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=74053&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=74053&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=74053&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=74053&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=74053&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=74053&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=74053&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74053&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=74053&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=74053&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=74053&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74053&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=74053&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=74053&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#207206) next »