From 6718576921796051c4566b71dec075500e63a266 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 6 Nov 2024 12:59:26 +0100 Subject: [PATCH] Move "no more objects" assert to right place 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 17c35d0ef..af26d122a 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);