From: Dmitry Stogov Date: Fri, 10 Feb 2017 07:31:43 +0000 (+0300) Subject: Fixed bug #74053 (Corrupted class entries on shutdown when a destructor spawns anothe... X-Git-Tag: php-7.2.0alpha1~389 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c39147d136d67bb3b9e36cdbef7944d831570af4;p=php 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 --- c39147d136d67bb3b9e36cdbef7944d831570af4 diff --cc NEWS index aba91c3dec,aba91c3dec..cd3df458c8 --- 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 45dee3e8c4,35b01e6a16..efe3379bd4 --- 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 8e54af2e34,f0c9d5e9aa..de450b102a --- 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 0000000000,e8fc02d387..b1936a58e9 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-- + ---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 a8674a5d11,0d84763823..9e139eff72 --- 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