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
This commit is contained in:
Ben Noordhuis 2024-11-06 14:54:52 +01:00 committed by GitHub
parent 37fe427d59
commit 0a706236d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);