WebAssembly / WebAssembly/wabt

`--no-check` produces malformed module

Open
#2,629 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
8.1k
Forks
827
Avg merge
4d 6h
Merged PRs (30d)
18

Description

This is effectively moved from https://github.com/WebAssembly/testsuite/issues/132 to here.

In short, compiling the following module with wat2wasm and --no-check:

(module 
  (func (export "test") 
    (data.drop 0))) 

leads to a WASM module that contains no data count section. According to the official specification, if a module uses data.drop or memory.init, it needs to contain a data count section.

Arguably this entire situation is bogus simply because we need to compile with --no-check for this to even compile. Interestingly enough though this seems to be only situation where --no-check leads a malformed and not an invalid module. In this case that causes some confusion when strictly interpreting the testsuite test cases w.r.t. if a module should fail to parse or fail to validate.

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

Reproduce the issue with wat2wasm, --no-check, and the WAT module shown in the report. Trace how data.drop is handled during module emission and check the existing compiler tests for a suitable regression case. Done means the generated module follows the specification's data-count requirement, with test coverage for this input.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
cli, compilers, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.