Files
sausage/userland/qjs/source/tests/wasi-stack-limit.js
T
surma d44f1d9677 Build separate native and WASI pipelines with shared multicall names
Checkpoint before integration and package validation.

Assisted-by: SurmAgent:unknown [read] [edit] [bash]
2026-11-12 09:36:27 +00:00

23 lines
611 B
JavaScript

let overflow;
// Use a large interpreter frame so QuickJS's linear-memory stack guard trips
// before Wasmtime's independent WebAssembly call stack is exhausted.
const args = Array(1024).fill("0").join(",");
const recurse = Function(
`return function recurse() { recurse(${args}); }`
)();
try {
recurse();
} catch (error) {
overflow = error;
}
if (!(overflow instanceof Error) ||
!/stack/i.test(overflow.message)) {
throw new Error(`expected a stack overflow, got ${overflow}`);
}
if (Function("return 20 + 22")() !== 42)
throw new Error("runtime is unusable after stack overflow");