Skip to content

Commit 178dcd4

Browse files
committed
Perform final GC before the object store is freed
free_object_storage intentionally does not free the object allocations to make sure that they show up as leaks. However, if the object is in the GC root buffer, the later GC run may end up freeing the allocation, hiding the leak. Avoid this by moving the final GC run before free_object_storage, the way it was done before fast_shutdown was integrated into core.
1 parent ba3bd4a commit 178dcd4

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

Zend/zend_execute_API.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,16 @@ void shutdown_executor(void) /* {{{ */
265265
zend_close_rsrc_list(&EG(regular_list));
266266
} zend_end_try();
267267

268+
if (!fast_shutdown) {
269+
zend_hash_graceful_reverse_destroy(&EG(symbol_table));
270+
271+
#if ZEND_DEBUG
272+
if (gc_enabled() && !CG(unclean_shutdown)) {
273+
gc_collect_cycles();
274+
}
275+
#endif
276+
}
277+
268278
zend_objects_store_free_object_storage(&EG(objects_store), fast_shutdown);
269279

270280
/* All resources and objects are destroyed. */
@@ -286,14 +296,6 @@ void shutdown_executor(void) /* {{{ */
286296
zend_hash_discard(EG(class_table), EG(persistent_classes_count));
287297
zend_cleanup_internal_classes();
288298
} else {
289-
zend_hash_graceful_reverse_destroy(&EG(symbol_table));
290-
291-
#if ZEND_DEBUG
292-
if (gc_enabled() && !CG(unclean_shutdown)) {
293-
gc_collect_cycles();
294-
}
295-
#endif
296-
297299
/* remove error handlers before destroying classes and functions,
298300
* so that if handler used some class, crash would not happen */
299301
if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {

0 commit comments

Comments
 (0)