Skip to content

Exceptions: handle try_table in unreachable code properly. - #11507

Merged
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
cfallin:unreachable-try-table
Aug 22, 2025
Merged

alexcrichton merged 1 commit into
bytecodealliance:mainfrom
cfallin:unreachable-try-table

Conversation

@cfallin

@cfallin cfallin commented Aug 22, 2025

Copy link
Copy Markdown
Member

Our Wasm-to-CLIF translator has a separate match-over-opcodes for unreachable code that mostly does nothing, but needs to push entries onto the control stack so that end-opcode processing works properly and tracks the bytecode's nesting (which is important because after an end we might re-enter reachable code).

Previously, try_table was not handled here -- it fell into the catchall case that did nothing -- so a try_table in unreachable code (most trivially, (unreachable) (try_table) in any block) would result in a panic. This PR fixes that by updating try_table handling to work like block and loop in unreachable contexts.

Fixes #11505.

Our Wasm-to-CLIF translator has a separate match-over-opcodes for
unreachable code that mostly does nothing, but needs to push entries
onto the control stack so that `end`-opcode processing works properly
and tracks the bytecode's nesting (which is important because after an
`end` we might re-enter reachable code).

Previously, `try_table` was not handled here -- it fell into the
catchall case that did nothing -- so a `try_table` in unreachable
code (most trivially, `(unreachable) (try_table)` in any block) would
result in a panic. This PR fixes that by updating `try_table` handling
to work like `block` and `loop` in unreachable contexts.

Fixes bytecodealliance#11505.
@cfallin
cfallin requested review from a team as code owners August 22, 2025 01:23
@cfallin
cfallin requested review from fitzgen and removed request for a team August 22, 2025 01:23
@alexcrichton
alexcrichton added this pull request to the merge queue Aug 22, 2025
Merged via the queue into bytecodealliance:main with commit 52922d6 Aug 22, 2025
@cfallin
cfallin deleted the unreachable-try-table branch August 22, 2025 15:02
bongjunj pushed a commit to prosyslab/wasmtime that referenced this pull request Oct 20, 2025
…ealliance#11507)

Our Wasm-to-CLIF translator has a separate match-over-opcodes for
unreachable code that mostly does nothing, but needs to push entries
onto the control stack so that `end`-opcode processing works properly
and tracks the bytecode's nesting (which is important because after an
`end` we might re-enter reachable code).

Previously, `try_table` was not handled here -- it fell into the
catchall case that did nothing -- so a `try_table` in unreachable
code (most trivially, `(unreachable) (try_table)` in any block) would
result in a panic. This PR fixes that by updating `try_table` handling
to work like `block` and `loop` in unreachable contexts.

Fixes bytecodealliance#11505.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic unwrapping None compiling exceptions-related fuzz test case

2 participants