Skip to content

wasmparser: require result equivalence for (on $t switch) handler#2564

Merged
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
vouillon:stack-switching-fix
Jul 13, 2026
Merged

wasmparser: require result equivalence for (on $t switch) handler#2564
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
vouillon:stack-switching-fix

Conversation

@vouillon

Copy link
Copy Markdown
Contributor

The resume/resume_throw handler clause (on $tag switch) was accepted when the switch tag's result types were merely a subtype of the resumed continuation's results. This is unsound, and does not follow the spec: the handler judgment has no subsumption rule, so (on tu switch) : t* together with the required hdl : t2* forces t* = t2*. The two result vectors must be equivalent, not just related by subtyping.

V8 and Binaryen already check for equivalence (see v8/v8@cf215c5).

@vouillon vouillon requested a review from a team as a code owner July 13, 2026 11:20
@vouillon vouillon requested review from dicej and removed request for a team July 13, 2026 11:20
The `resume`/`resume_throw` handler clause `(on $tag switch)` was
accepted when the switch tag's result types were merely a *subtype* of
the resumed continuation's results. This is unsound, and does not follow
the spec: the handler judgment has no subsumption rule, so `(on tu
switch) : t*` together with the required `hdl : t2*` forces `t* = t2*`.
The two result vectors must be equivalent, not just related by
subtyping.

V8 and Binaryen already check for equivalence.
@vouillon vouillon force-pushed the stack-switching-fix branch from d85c531 to 685b3ad Compare July 13, 2026 12:09

@alexcrichton alexcrichton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@alexcrichton alexcrichton added this pull request to the merge queue Jul 13, 2026
Merged via the queue into bytecodealliance:main with commit 1b805bb Jul 13, 2026
37 checks passed
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.

2 participants