Skip to content

Fix for ArrayIndexOutOfBoundsException in Frame.merge#79

Merged
andreaTP merged 3 commits into
bytecodealliance:mainfrom
RefuX:fix/wasm-aioobe-bytecode
Jul 1, 2026
Merged

Fix for ArrayIndexOutOfBoundsException in Frame.merge#79
andreaTP merged 3 commits into
bytecodealliance:mainfrom
RefuX:fix/wasm-aioobe-bytecode

Conversation

@RefuX

@RefuX RefuX commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

I was hitting this error compiling my own wasm module at runtime.

I wasn't sure whether to file a bug or open a PR — this is outside my area of expertise, and I put the fix together with a lot of help from an AI assistant. So I completely understand if the fix shows a lack of deep understanding, because that would be completely correct.

Symptom: ArrayIndexOutOfBoundsException in ASM Frame.merge ("incompatible stack heights") during runtime compilation.

Cause: when a try_table catch branches out to an enclosing block, the operand-stack values belonging to the blocks it's exiting must be dropped (keeping the caught values), exactly like a normal branch — the catch handler wasn't doing that.

Fix: emit the same DROP_KEEP unwind the compiler already uses for ordinary branches before the catch branches to its target.

@RefuX RefuX requested a review from andreaTP as a code owner July 1, 2026 16:13

@andreaTP andreaTP left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @RefuX , I checked your wat reproducers carefully against V8 behavior and everything looks correct, I'm reviewing the PR but looks a great starting point.

This also seems worth a patch release, you are clearly targeting a specific .wasm payload, let me know when all issues are addressed and I'll trigger the release.

@andreaTP andreaTP merged commit bd229ce into bytecodealliance:main Jul 1, 2026
25 checks passed
@RefuX

RefuX commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@andreaTP Thanks so much for the help!

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