Skip to content

Regression when using instantiateWasm #23572

@hoodmane

Description

@hoodmane

#23157 broke the following code:

Reproducer

Make a file called main.mjs with:

import createModule from "./a.mjs";
import { readFile } from "node:fs/promises";

function instantiateWasm(imports, successCallback) {
  (async function () {
    const r = await readFile("./a.wasm");
    const binary = new Uint8Array(r.buffer, r.byteOffset, r.byteLength);
    let res = await WebAssembly.instantiate(binary, imports);
    const { instance, module } = res;
    successCallback(instance, module);
  })();
  return {};
}

createModule({ instantiateWasm });

then:

echo "int main(){ return 0; }" > a.c
emcc -o a.mjs a.c
node main.mjs

Behavior

Before #23157, does nothing and returns with exit code 0.
After #23157, fails with

file:///home/rchatham/repro/a.mjs:1387
  _emscripten_stack_init();
  ^

TypeError: _emscripten_stack_init is not a function
    at stackCheckInit (file:///home/rchatham/repro/a.mjs:1387:3)
    at run (file:///home/rchatham/repro/a.mjs:1399:3)
    at removeRunDependency (file:///home/rchatham/repro/a.mjs:551:7)
    at receiveInstance (file:///home/rchatham/repro/a.mjs:752:5)
    at file:///home/rchatham/repro/main.mjs:10:5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions