Skip to content

Multiple sequential await calls in evalCodeAsync fail with "Lifetime not alive" #258

@0xKoller

Description

@0xKoller

When using newAsyncContext() with newAsyncifiedFunction(), the first await on a host function works correctly, but the second sequential await causes "Lifetime not alive" errors and crashes with Assertion failed: list_empty(&rt->gc_obj_list).

Reproduction:

import { newAsyncContext } from "quickjs-emscripten";

const ctx = await newAsyncContext();

const fn = ctx.newAsyncifiedFunction("get", async (...args) => {
  const path = ctx.dump(args[0]);
  return ctx.newString(JSON.stringify({ path }));
});
ctx.setProp(ctx.global, "get", fn);
fn.dispose();

// Single await - WORKS
const r1 = await ctx.evalCodeAsync(`(async () => { return await get("/a") })()`);

// Two sequential awaits - CRASHES
const r2 = await ctx.evalCodeAsync(`
  (async () => {
    const a = await get("/a");
    const b = await get("/b");  // Crashes here
    return [a, b];
  })()
`);

Expected: Both awaits resolve sequentially.
Actual: Second await causes QuickJSUseAfterFree: Lifetime not alive followed by Assertion failed: list_empty(&rt->gc_obj_list) on runtime disposal.

The issue is in quickjs-emscripten v0.32.0 with the ASYNCIFY variant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions