-
Notifications
You must be signed in to change notification settings - Fork 129
Closed
Description
Hi, thank you for your amazing library. Recently I met a problem related to asyncify stack memory region.
Run this code in node.js:
const { newAsyncContext } = require('quickjs-emscripten');
async function main() {
const context = await newAsyncContext();
let times = 0;
const fooHandle = context.newAsyncifiedFunction('foo', async () => {
times++;
console.log('foo called', times);
});
fooHandle.consume((fn) => context.setProp(context.global, 'foo', fn));
await context.evalCodeAsync(`
function a(){
foo();
a();
}
a();
`);
}
main();And it will output:
foo called 1
foo called 2
foo called 3
foo called 4
foo called 5
foo called 6
foo called 7
foo called 8
foo called 9
foo called 10
foo called 11
foo called 12
Aborted(RuntimeError: unreachable)
/home/yar2001/Documents/code/warriors-mono/node/node_modules/quickjs-emscripten/dist/generated/emscripten-module.WASM_RELEASE_ASYNCIFY.js:147
a.onAbort(b); b = "Aborted(" + b + ")"; B(b); H = !0; b = new WebAssembly.RuntimeError(b + ". Build with -sASSERTIONS for more info."); l(b); throw b; }
^
RuntimeError: Aborted(RuntimeError: unreachable). Build with -sASSERTIONS for more info.
at F (/home/yar2001/Documents/code/warriors-mono/node/node_modules/quickjs-emscripten/dist/generated/emscripten-module.WASM_RELEASE_ASYNCIFY.js:147:71)
at V (/home/yar2001/Documents/code/warriors-mono/node/node_modules/quickjs-emscripten/dist/generated/emscripten-module.WASM_RELEASE_ASYNCIFY.js:195:13)
at Aa.c.<computed> (/home/yar2001/Documents/code/warriors-mono/node/node_modules/quickjs-emscripten/dist/generated/emscripten-module.WASM_RELEASE_ASYNCIFY.js:202:87)
at /home/yar2001/Documents/code/warriors-mono/node/node_modules/quickjs-emscripten/dist/generated/emscripten-module.WASM_RELEASE_ASYNCIFY.js:217:66
at /home/yar2001/Documents/code/warriors-mono/node/node_modules/quickjs-emscripten/dist/module.js:130:25
Node.js v18.13.0
The aborted(runtimeerror: unreachable) error is likely caused by a stack overflow in the asyncify stack memory region. Notice that the function is nested 12 times and is unsuitable for some use cases (such as a little complicated web service). The linker option ASYNCIFY_STACK_SIZE is related to the size of the memory region, so maybe we can increase it to 81920 or more (20x than default).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels