WebAssembly / WebAssembly/binaryen

Asyncify "OOM" leaves broken state

Open
#3,839 17 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
8.6k
Forks
885
Avg merge
1d 19h
Merged PRs (30d)
69

Description

Right now, emitted Asyncify unwind/rewind mechanisms always stores all the variables while unwinding, and only performs bound checks in points like asyncify_stop_unwind when memory outside of bounds is already corrupted.

This leaves module in a broken state: even if you catch & handle the original error, calling into other exports after this point can result in all sorts of broken behaviour.

A better solution would be to perform bound checks right before storing the locals - their size is known in advance, so such condition should be fairly simple and wouldn't add any noticeable overhead, but would improve reliability a lot.

cc @kripken thoughts?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the emitted Asyncify unwind/rewind mechanisms and the existing bound checks at points such as asyncify_stop_unwind. Verify how much local storage is required before unwinding, then confirm that an out-of-bounds condition is handled before locals are stored and that the module remains usable after the original error is caught.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.