You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parsing a WASM module using wasm-opt containing a try_table instruction yields the error [parse exception: bad node code 31 (at 0:9801)]. --debug prints the contents of the module up to the end of the function before the one containing the try_table. --enable-exception-handling is on and the throw instruction compiles perfectly fine.
I searched quite a lot but couldn't find any information regarding this, is there any way to get modern exceptions working with wasm-opt?
Are you perhaps on an older version that does not have that support yet?
I had made sure that the wasm-opt installed via my package manager was up to date, but your question got me to run where wasm-opt and it turns out I had an older version installed via Cargo that was taking precedence 🙃
Thank you, and sorry for the false report
I'm now having a different issue, but I can open a separate issue for that (/keep debugging it) if desired. UNREACHABLE executed at /build/emscripten/src/binaryen/src/passes/Flatten.cpp:231! zsh: IOT instruction (core dumped)
We hit the same Flatten.cpp:231 assertion with wasm-opt -O4 on standardized-EH modules containing try_table, reproducible with Binaryen 125 and current main.
Retrying with --skip-pass=flatten works: all remaining O4 passes complete and the output validates and runs correctly.
Is try_table support in Flatten on the roadmap? If not, would you accept a minimal patch making Flatten gracefully skip functions containing unsupported EH/GC constructs instead of aborting the entire -O4 optimization?
@ttraenkler Hmm, I think we shouldn't make Flatten skip things, as e.g. Asyncify depends on Flatten actually running - it only works on the flattened form. That is, if Flatten skips a function, Asyncify would need to as well - but that means Asyncify is no longer valid.
Is --skip-pass=flatten not a reasonable workaround for now? I don't have near-term plans to make Flatten work on try_table, but I hope someone else finds time (a PR would be welcome).
Another option is to add --maybe-flatten which only flattens what it can, and -O4 would run that. I'd accept that PR too.
@kripken Thanks — agreed --skip-pass=flattenor --maybe-flatten sounds like the cleaner upstream solution until this can be implemented. I implemented a narrow fallback in our pipeline: when wasm-opt -O4 fails specifically because Flatten cannot process try_table, we retry that module with --skip-pass=flatten. If this workaround turns out not to be sufficient I will look into it further.
I would suggest to reopen this issue to keep track of it. This surfaced because Wasmtime 47 rejects the legacy EH opcodes, while the current Binaryen Flatten pass does not yet handle standardized try_table so I assume others will hit this issue too.
Running the Flatten pass on it (Binaryen 133, through its C API, as wasm-opt --enable-exception-handling --flatten repro.wat does) aborts with unexpected expr type / UNREACHABLE executed at src/passes/Flatten.cpp:231, as does -O4 on any module holding a try_table.
Activity
kripken commentedon Feb 24, 2026
This is stable and tested:
Are you perhaps on an older version that does not have that support yet?
(If you are on a recent version, perhaps you have a typo somehow, please provide a failing testcase.)
Pspritechologist commentedon Feb 25, 2026
I had made sure that the
wasm-optinstalled via my package manager was up to date, but your question got me to runwhere wasm-optand it turns out I had an older version installed via Cargo that was taking precedence 🙃Thank you, and sorry for the false report
I'm now having a different issue, but I can open a separate issue for that (/keep debugging it) if desired.
UNREACHABLE executed at /build/emscripten/src/binaryen/src/passes/Flatten.cpp:231! zsh: IOT instruction (core dumped)kripken commentedon Feb 25, 2026
The Flatten pass specifically does not yet support GC or Exceptions. But it is not normally run. What command are you using?
Pspritechologist commentedon Feb 25, 2026
-O4, and that makes sense thank you :)I'll review the passes more closely.
kripken commentedon Feb 25, 2026
Ok, then
-O4is not supported with all features. We should probably update the docs about it, though I hope we fix Flatten eventually...ttraenkler commentedon Aug 21, 2026
We hit the same Flatten.cpp:231 assertion with wasm-opt -O4 on standardized-EH modules containing try_table, reproducible with Binaryen 125 and current main.
Retrying with --skip-pass=flatten works: all remaining O4 passes complete and the output validates and runs correctly.
Is try_table support in Flatten on the roadmap? If not, would you accept a minimal patch making Flatten gracefully skip functions containing unsupported EH/GC constructs instead of aborting the entire -O4 optimization?
kripken commentedon Aug 21, 2026
@ttraenkler Hmm, I think we shouldn't make Flatten skip things, as e.g. Asyncify depends on Flatten actually running - it only works on the flattened form. That is, if Flatten skips a function, Asyncify would need to as well - but that means Asyncify is no longer valid.
Is
--skip-pass=flattennot a reasonable workaround for now? I don't have near-term plans to make Flatten work on try_table, but I hope someone else finds time (a PR would be welcome).Another option is to add
--maybe-flattenwhich only flattens what it can, and-O4would run that. I'd accept that PR too.ttraenkler commentedon Aug 21, 2026
@kripken Thanks — agreed
--skip-pass=flattenor--maybe-flattensounds like the cleaner upstream solution until this can be implemented. I implemented a narrow fallback in our pipeline: whenwasm-opt -O4fails specifically because Flatten cannot processtry_table, we retry that module with--skip-pass=flatten. If this workaround turns out not to be sufficient I will look into it further.I would suggest to reopen this issue to keep track of it. This surfaced because Wasmtime 47 rejects the legacy EH opcodes, while the current Binaryen Flatten pass does not yet handle standardized
try_tableso I assume others will hit this issue too.kripken commentedon Aug 21, 2026
Sounds good, reopening.
[-]Error Parsing `try_table` Instruction[/-][+]Support `try_table` in Flatten[/+]rayan-mazouz commentedon Nov 30, 2026
A minimal reproduction, in case it helps whoever picks this up:
Running the Flatten pass on it (Binaryen 133, through its C API, as
wasm-opt --enable-exception-handling --flatten repro.watdoes) aborts withunexpected expr type/UNREACHABLE executed at src/passes/Flatten.cpp:231, as does-O4on any module holding atry_table.