quickjs-emscripten-sync icon indicating copy to clipboard operation
quickjs-emscripten-sync copied to clipboard

Garbage collection error when trying to dispose of date in array

Open AashJ opened this issue 1 year ago • 1 comments

  test.only("Date in array", async () => {
    const ctx = (await getQuickJS()).newContext();
    const arena = new Arena(ctx, { isMarshalable: true });
    const scope = { results: [new Date(2022, 7, 26)] };
    arena.expose(scope);

    const evalResult = arena.evalCode("results[0]");
    console.log(evalResult);
    expect(evalResult).instanceOf(Date);

    arena.dispose();
    ctx.dispose();
  });

When running this test, an error is thrown:

RuntimeError: Aborted(Assertion failed: list_empty(&rt->gc_obj_list), at: quickjs/quickjs.c,1983,JS_FreeRuntime). Build with -s ASSERTIONS=1 for more info.

My best guess is the quickjs handle isn't being properly disposed of, but i'm not 100% sure. Working on a PR, but thought I'd flag here incase anyone had ideas.

AashJ avatar Aug 06 '24 22:08 AashJ