-
-
Notifications
You must be signed in to change notification settings - Fork 442
Description
(Apologise for the duplication - accidentally created the ticket from the wrong GH account)
Describe the bug
When compiled to WASM (wasm-pack --debug
), the parser exceeds the call stack when fed certain input. I presumed it was getting stuck in an infinite recursion loop, but after compiling the exact same code in release mode, the issue vanished.
This implies that the root cause is that, in debug mode, the parser is prone to overflowing the stack simply due to being very recursive in its implementation.
To Reproduce
This is the minimal Rust code I found that reproduces the bug:
#[wasm_bindgen]
pub fn fail_case() {
let src = r#"
const a = function () {
b((c = d([])))
}
"#;
let context = &mut boa_engine::Context::builder().build().unwrap();
let source = boa_engine::Source::from_bytes(src);
let _module = boa_engine::Module::parse(source, None, context).unwrap();
}
Compiling to WASM and calling from JS in Chrome yields this stack trace:

Expected behavior
Successful parse without a stack overflow
Build environment (please complete the following information):
- OS: MacOS
- Version: Sequoia 15.5
- Target triple: wasm32-unknown-unknown
- Rustc version: rustc 1.87.0 (17067e9ac 2025-05-09)