com php-src: Fixed bug #74053 (Corrupted class entries on shutdown when a destructor spawns another object). (jim at commercebyte dot com): NEWS
Zend/tests/bug64720.phpt Zend/tests/bug68652.phpt Zend/tests/bug74053.phpt main/main.c
| From: | Dmitry Stogov | Date: | Fri, 10 Feb 2017 07:31:43 +0000 |
| Subject: | com php-src: Fixed bug #74053 (Corrupted class entries on shutdown when a destructor spawns another object). (jim at commercebyte dot com): NEWS Zend/tests/bug64720.phpt Zend/tests/bug68652.phpt Zend/tests/bug74053.phpt main/main.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-97054@lists.php.net to get a copy of this message | ||
Commit: c39147d136d67bb3b9e36cdbef7944d831570af4
Author: Dmitry Stogov <dmitry@zend.com> Fri, 10 Feb 2017 10:31:43 +0300
Parents: 1760b031eab5cac900bdbb9c72827b572fce52cf 1b1399c95d1358b23f234c14e84dda9b5007904e
Branches: master
Link: http://git.php.net/?p=php-src..git;a=commitdiff;h=c39147d136d67bb3b9e36cdbef7944d831570af4
Log:
Fixed bug #74053 (Corrupted class entries on shutdown when a destructor spawns another object). (jim
at commercebyte dot com)
Merge branch 'master' of github.com:commercebyte/php-src
* 'master' of github.com:commercebyte/php-src:
Added EG(flags) - executor global flags EG_FLAGS_IN_SHUTDOWN - is set when PHP is in shutdown
state
newly added zend_object_store.no_reuse is redefined as a global zend_object_store_no_reuse, to
avoid alignment issues
Alignment fix, as per @nikic
The test scripts bug64720.phpt and bug68652.phpt were relying on the buggy behavior, when PHP
returns "Undefined static property" error due to class entry corruption. With my fix for
bug 74053, both tests return no errors now, I corrected the EXPECTF accordingly
Bug Fix: Corrupted class entries on shutdown when a destructor spawns another object (C) 2017
CommerceByte Consulting
Bugs:
https://bugs.php.net/74053
https://bugs.php.net/64720
https://bugs.php.net/68652
Changed paths:
MM NEWS
MM Zend/tests/bug64720.phpt
MM Zend/tests/bug68652.phpt
AM Zend/tests/bug74053.phpt
MM main/main.c
Diff:
diff --cc NEWS
index aba91c3,aba91c3..cd3df45
--- a/NEWS
+++ b/NEWS
@@@ -28,6 -28,6 +28,8 @@@ PH
. Fixed bug #73973 (assertion error in debug_zval_dump). (andrewnester)
. Fixed bug #73987 (Method compatibility check looks to original
definition and not parent). (pmmaga)
++ . Fixed bug #74053 (Corrupted class entries on shutdown when a destructor
++ spawns another object). (jim at commercebyte dot com)
- BCMath:
. Fixed bug #46564 (bcmod truncates fractionals). (liborm85)
diff --cc Zend/tests/bug64720.phpt
index 45dee3e,35b01e6..efe3379
--- a/Zend/tests/bug64720.phpt
+++ b/Zend/tests/bug64720.phpt
@@@ -44,9 -44,4 +44,6 @@@ $foo = new Foo()
$bar = new Bar();
$bar->test();
?>
----EXPECTF--
- Fatal error: Uncaught Error: Access to undeclared static property: Stat::$requests in
%sbug64720.php:12
- Stack trace:
- #0 [internal function]: Stat->__destruct()
- #1 {main}
- thrown in %sbug64720.php on line 12
++OK
++--EXPECT--
++OK
diff --cc Zend/tests/bug68652.phpt
index 8e54af2,f0c9d5e...de450b1
--- a/Zend/tests/bug68652.phpt
+++ b/Zend/tests/bug68652.phpt
@@@ -36,11 -36,4 +36,6 @@@ class Bar
$foo = new Foo();
?>
----EXPECTF--
- Fatal error: Uncaught Error: Access to undeclared static property: Bar::$instance in
%sbug68652.php:%d
- Stack trace:
- #0 %s(%d): Bar::getInstance()
- #1 [internal function]: Foo->__destruct()
- #2 {main}
- thrown in %sbug68652.php on line %d
-
++OK
++--EXPECT--
++OK
diff --cc Zend/tests/bug74053.phpt
index 0000000,e8fc02d..b1936a5
mode 000000,100644..100644
--- a/Zend/tests/bug74053.phpt
+++ b/Zend/tests/bug74053.phpt
@@@ -1,0 -1,43 +1,43 @@@
+ --TEST--
+ Bug #74053 (Corrupted class entries on shutdown when a destructor spawns another object)
+ --FILE--
+ <?php
+ class b {
+ function __destruct() {
+ echo "b::destruct\n";
+ }
+ }
+ class a {
+ static $b;
+ static $new;
+ static $max = 10;
+ function __destruct() {
+ if (self::$max-- <= 0) return;
+ echo "a::destruct\n";
+ self::$b = new b;
+ self::$new[] = new a;
+ }
+ }
+ new a;
+ ?>
---EXPECTF--
++--EXPECT--
+ a::destruct
+ b::destruct
+ a::destruct
+ b::destruct
+ a::destruct
+ b::destruct
+ a::destruct
+ b::destruct
+ a::destruct
+ b::destruct
+ a::destruct
+ b::destruct
+ a::destruct
+ b::destruct
+ a::destruct
+ b::destruct
+ a::destruct
+ b::destruct
+ a::destruct
+ b::destruct
diff --cc main/main.c
index a8674a5,0d84763..9e139ef
--- a/main/main..c
+++ b/main/main.c
@@@ -1798,7 -1798,9 +1798,9 @@@ void php_request_shutdown_for_hook(voi
void php_request_shutdown(void *dummy)
{
zend_bool report_memleaks;
-
+
+ EG(flags) |= EG_FLAGS_IN_SHUTDOWN;
+
report_memleaks = PG(report_memleaks);
/* EG(current_execute_data) points into nirvana and therefore cannot be safely accessed