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