WebAssembly / WebAssembly/spec

Incorrect implementations of unreachable `ref.as_non_null` validation

Open
#2,235 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
3.5k
Forks
539
Avg merge
2d 1h
Merged PRs (30d)
13

Description

V8, SpiderMonkey, and JavaScriptCore all say this invalid module is valid:

(module
  (func $invalid
    (local $i32 i32)
    (unreachable)
    (ref.as_non_null)
    (local.set $i32)
  )
)

I guess production engines never bothered to implement (ref ⊥), so they just have the ref.as_non_null push in this situation. The reference interpreter and wasm-tools get this right. WABT gets this wrong. Binaryen doesn't even try to validate unreachable code correctly.

We should probably add a spec test for this, but OTOH that would be really annoying for the engines for no real benefit.

Maybe it's time to revisit the relaxed dead code validation proposal 🤔

cc @conrad-watt

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 reproducing the invalid module with the reference interpreter and wasm-tools, then compare their behavior with WABT, Binaryen, and the reported engines. Read the relaxed dead code validation proposal and determine whether the expected validation rule and a spec test have been agreed; done means a recorded decision and corresponding test or follow-up.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
compilers, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.