@@ -316,6 +316,21 @@ void shutdown_executor(void) /* {{{ */
316
316
}
317
317
} ZEND_HASH_FOREACH_END ();
318
318
319
+ /* Also release error and exception handlers, which may hold objects. */
320
+ if (Z_TYPE (EG (user_error_handler )) != IS_UNDEF ) {
321
+ zval_ptr_dtor (& EG (user_error_handler ));
322
+ ZVAL_UNDEF (& EG (user_error_handler ));
323
+ }
324
+
325
+ if (Z_TYPE (EG (user_exception_handler )) != IS_UNDEF ) {
326
+ zval_ptr_dtor (& EG (user_exception_handler ));
327
+ ZVAL_UNDEF (& EG (user_exception_handler ));
328
+ }
329
+
330
+ zend_stack_clean (& EG (user_error_handlers_error_reporting ), NULL , 1 );
331
+ zend_stack_clean (& EG (user_error_handlers ), (void (* )(void * ))ZVAL_PTR_DTOR , 1 );
332
+ zend_stack_clean (& EG (user_exception_handlers ), (void (* )(void * ))ZVAL_PTR_DTOR , 1 );
333
+
319
334
#if ZEND_DEBUG
320
335
if (gc_enabled () && !CG (unclean_shutdown )) {
321
336
gc_collect_cycles ();
@@ -342,22 +357,6 @@ void shutdown_executor(void) /* {{{ */
342
357
zend_hash_discard (EG (class_table ), EG (persistent_classes_count ));
343
358
zend_cleanup_internal_classes ();
344
359
} else {
345
- /* remove error handlers before destroying classes and functions,
346
- * so that if handler used some class, crash would not happen */
347
- if (Z_TYPE (EG (user_error_handler )) != IS_UNDEF ) {
348
- zval_ptr_dtor (& EG (user_error_handler ));
349
- ZVAL_UNDEF (& EG (user_error_handler ));
350
- }
351
-
352
- if (Z_TYPE (EG (user_exception_handler )) != IS_UNDEF ) {
353
- zval_ptr_dtor (& EG (user_exception_handler ));
354
- ZVAL_UNDEF (& EG (user_exception_handler ));
355
- }
356
-
357
- zend_stack_clean (& EG (user_error_handlers_error_reporting ), NULL , 1 );
358
- zend_stack_clean (& EG (user_error_handlers ), (void (* )(void * ))ZVAL_PTR_DTOR , 1 );
359
- zend_stack_clean (& EG (user_exception_handlers ), (void (* )(void * ))ZVAL_PTR_DTOR , 1 );
360
-
361
360
zend_vm_stack_destroy ();
362
361
363
362
if (EG (full_tables_cleanup )) {
0 commit comments