summaryrefslogtreecommitdiff
path: root/Zend/zend_execute_API.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-08-28 15:33:51 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-08-28 17:04:35 +0200
commit2709d6a2508abfdda1b84f0426ae644c703180ed (patch)
tree901cc7da802101e74f7b2ae3d6feab9c329d06f0 /Zend/zend_execute_API.c
parentec9a96dc60c3fd2cccf5b21033a0e87807366bdb (diff)
downloadphp-git-2709d6a2508abfdda1b84f0426ae644c703180ed.tar.gz
Destroy error handlers before final GC run
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r--Zend/zend_execute_API.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index ac2ee8ed7f..210817fef1 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -318,6 +318,21 @@ void shutdown_executor(void) /* {{{ */
}
} ZEND_HASH_FOREACH_END();
+ /* Also release error and exception handlers, which may hold objects. */
+ if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
+ zval_ptr_dtor(&EG(user_error_handler));
+ ZVAL_UNDEF(&EG(user_error_handler));
+ }
+
+ if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
+ zval_ptr_dtor(&EG(user_exception_handler));
+ ZVAL_UNDEF(&EG(user_exception_handler));
+ }
+
+ zend_stack_clean(&EG(user_error_handlers_error_reporting), NULL, 1);
+ zend_stack_clean(&EG(user_error_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1);
+ zend_stack_clean(&EG(user_exception_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1);
+
#if ZEND_DEBUG
if (gc_enabled() && !CG(unclean_shutdown)) {
gc_collect_cycles();
@@ -344,22 +359,6 @@ void shutdown_executor(void) /* {{{ */
zend_hash_discard(EG(class_table), EG(persistent_classes_count));
zend_cleanup_internal_classes();
} else {
- /* remove error handlers before destroying classes and functions,
- * so that if handler used some class, crash would not happen */
- if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
- zval_ptr_dtor(&EG(user_error_handler));
- ZVAL_UNDEF(&EG(user_error_handler));
- }
-
- if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
- zval_ptr_dtor(&EG(user_exception_handler));
- ZVAL_UNDEF(&EG(user_exception_handler));
- }
-
- zend_stack_clean(&EG(user_error_handlers_error_reporting), NULL, 1);
- zend_stack_clean(&EG(user_error_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1);
- zend_stack_clean(&EG(user_exception_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1);
-
zend_vm_stack_destroy();
if (EG(full_tables_cleanup)) {