From 0a706236d78991c064ea14257079003e6f62ce6d Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 6 Nov 2024 14:54:52 +0100 Subject: [PATCH] Move "no more objects" assert to right place (#649) No test because I can only get it to trigger with qjs, not run-test262, but the problem is that we need to run FinalizationRegistry finalizers before asserting no objects remain. Fixes: https://github.com/quickjs-ng/quickjs/issues/648 --- quickjs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/quickjs.c b/quickjs.c index 17c35d0..af26d12 100644 --- a/quickjs.c +++ b/quickjs.c @@ -2106,7 +2106,6 @@ void JS_FreeRuntime(JSRuntime *rt) printf("Secondary object leaks: %d\n", count); } #endif - assert(list_empty(&rt->gc_obj_list)); /* free the classes */ for(i = 0; i < rt->class_count; i++) { @@ -2237,6 +2236,9 @@ void JS_FreeRuntime(JSRuntime *rt) js_free_rt(rt, fs); } + // FinalizationRegistry finalizers have run, no objects should remain + assert(list_empty(&rt->gc_obj_list)); + { JSMallocState *ms = &rt->malloc_state; rt->mf.js_free(ms->opaque, rt);