]> granicus.if.org Git - php/commitdiff
Perform final GC before the object store is freed
authorNikita Popov <nikita.ppv@gmail.com>
Sun, 16 Sep 2018 11:42:00 +0000 (13:42 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 17 Sep 2018 08:13:55 +0000 (10:13 +0200)
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.

Zend/zend_execute_API.c

index 57a7e80819ebdd63dbd63f990d787215af0d8331..5b6012767c6d358b1501b758e23fe776850ca31d 100644 (file)
@@ -265,6 +265,16 @@ void shutdown_executor(void) /* {{{ */
                zend_close_rsrc_list(&EG(regular_list));
        } zend_end_try();
 
+       if (!fast_shutdown) {
+               zend_hash_graceful_reverse_destroy(&EG(symbol_table));
+
+#if ZEND_DEBUG
+               if (gc_enabled() && !CG(unclean_shutdown)) {
+                       gc_collect_cycles();
+               }
+#endif
+       }
+
        zend_objects_store_free_object_storage(&EG(objects_store), fast_shutdown);
 
        /* All resources and objects are destroyed. */
@@ -286,14 +296,6 @@ void shutdown_executor(void) /* {{{ */
                zend_hash_discard(EG(class_table), EG(persistent_classes_count));
                zend_cleanup_internal_classes();
        } else {
-               zend_hash_graceful_reverse_destroy(&EG(symbol_table));
-
-#if ZEND_DEBUG
-               if (gc_enabled() && !CG(unclean_shutdown)) {
-                       gc_collect_cycles();
-               }
-#endif
-
                /* 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) {