WebAssembly / WebAssembly/binaryen

Missing validation error

Open
#8,785 1 comment 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

See jj.tar.gz.

Unpack via:

% tar xvzf jj.tar.gz
...

When running with V8 we get a validation error:

% d8 $PWD/pkg/dart2wasm/bin/run_wasm.js  -- $PWD/jj.mjs $PWD/jj.wasm   
run_wasm.js:346: CompileError: WebAssembly.compile(): Compiling function #181:"main" failed: not enough arguments on the stack for drop (need 1, got 0) @+25996
  }
  ^
CompileError: WebAssembly.compile(): Compiling function #181:"main" failed: not enough arguments on the stack for drop (need 1, got 0) @+25996

1 pending unhandled Promise rejection(s) detected.

Though optimizing with wasm-opt works fine and the result runs:

% wasm-opt --enable-gc --enable-reference-types --enable-multivalue --enable-exception-handling --enable-nontrapping-float-to-int --enable-sign-ext --enable-bulk-memory --enable-threads --enable-simd '--no-inline=*<noInline>*' --traps-never-happen -g -Os --gufa -Os -Os jj.wasm -o jj.wasm  
% d8 $PWD/pkg/dart2wasm/bin/run_wasm.js  -- $PWD/jj.mjs $PWD/jj.wasm
%

Is wasm-opt not supposed to issue a validation error here as well? (even though the corresponding code is unreachable)

        local.get $reporter
        drop
        drop
        block $label2
          unreachable
        end
        drop

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

Unpack jj.tar.gz and reproduce the V8 validation error with pkg/dart2wasm/bin/run_wasm.js, jj.mjs, and jj.wasm. Compare wasm-opt's handling of the shown unreachable WAT sequence with V8's validation, and add or update a regression test so the tools agree on whether this module is valid.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.