From: foobar Date: Sun, 24 Apr 2005 14:49:00 +0000 (+0000) Subject: MFH: - Execute destructors earlier X-Git-Tag: php-5.0.5RC1~387 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb393b600cf645d639d9ca5fc9aaa4bdcefd9e65;p=php MFH: - Execute destructors earlier --- diff --git a/NEWS b/NEWS index 73f401cd0b..c9f698b4bf 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,8 @@ PHP NEWS - Fixed bug #32753 (Undefined constant SQLITE_NOTADB). (Ilia) - Fixed bug #32699 (pg_affected_rows() was defined when it was not available). (Derick) +- Fixed bug #32686 (Require/include file in destructor causes segfault). + (Marcus) - Fixed bug #32682 (ext/mssql: Error on module shutdown when called from activescript). (Frank) - Fixed bug #32647 (Using register_shutdown_function() with invalid callback diff --git a/Zend/tests/bug20240.phpt b/Zend/tests/bug20240.phpt index acf673a277..4395044006 100755 --- a/Zend/tests/bug20240.phpt +++ b/Zend/tests/bug20240.phpt @@ -39,5 +39,5 @@ echo "Done\n"; 2 3 Done -test::destructor test::__destruct +test::destructor diff --git a/Zend/zend.c b/Zend/zend.c index 3467b61a04..0fb5c59656 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -803,6 +803,13 @@ void zend_deactivate_modules(TSRMLS_D) } zend_end_try(); } +void zend_call_destructors(TSRMLS_D) +{ + zend_try { + shutdown_destructors(TSRMLS_C); + } zend_end_try(); +} + void zend_deactivate(TSRMLS_D) { /* we're no longer executing anything */ diff --git a/Zend/zend.h b/Zend/zend.h index e70c8d1972..095a8c301d 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -452,6 +452,7 @@ END_EXTERN_C() void zend_activate(TSRMLS_D); void zend_deactivate(TSRMLS_D); +void zend_call_destructors(TSRMLS_D); void zend_activate_modules(TSRMLS_D); void zend_deactivate_modules(TSRMLS_D); void zend_post_deactivate_modules(TSRMLS_D); diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index d4d02a49e7..2ff6ba25eb 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -49,6 +49,7 @@ ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data_pt void init_executor(TSRMLS_D); void shutdown_executor(TSRMLS_D); +void shutdown_destructors(TSRMLS_D); ZEND_API void execute(zend_op_array *op_array TSRMLS_DC); ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC); ZEND_API int zend_is_true(zval *op); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 3d31332b6e..ea944e0840 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -185,6 +185,15 @@ void init_executor(TSRMLS_D) EG(This) = NULL; } +void shutdown_destructors(TSRMLS_D) { + zend_try { + zend_objects_store_call_destructors(&EG(objects_store) TSRMLS_CC); + } zend_catch { + /* if we couldn't destruct cleanly, mark all objects as destructed anyway */ + zend_objects_store_mark_destructed(&EG(objects_store) TSRMLS_CC); + } zend_end_try(); +} + void shutdown_executor(TSRMLS_D) { zend_try { @@ -204,7 +213,6 @@ void shutdown_executor(TSRMLS_D) } */ zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_deactivator TSRMLS_CC); - zend_objects_store_call_destructors(&EG(objects_store) TSRMLS_CC); zend_hash_graceful_reverse_destroy(&EG(symbol_table)); } zend_catch { /* if we couldn't destruct cleanly, mark all objects as destructed anyway */ diff --git a/main/main.c b/main/main.c index 32f2b6883c..9f067bd0ac 100644 --- a/main/main.c +++ b/main/main.c @@ -1193,6 +1193,10 @@ void php_request_shutdown(void *dummy) sapi_send_headers(TSRMLS_C); } zend_end_try(); + zend_try { + zend_call_destructors(TSRMLS_C); + } zend_end_try(); + if (PG(modules_activated)) zend_try { php_call_shutdown_functions(TSRMLS_C); } zend_end_try();