WebAssembly / WebAssembly/binaryen

Fuzzer generates invalid code for table initializers

Open
#8,911 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

I ran --translate-to-fuzz on the following seed file:

(module
  (import "env" "table" (table 1 1 (ref exn)))
)
 bin/wasm-opt -ttf -if seed.wast -all /dev/null -o /dev/null

And hit a fatal error that validation failed, since a ref.as_non_null was generated in a constant expression (the table initializer):

[wasm-validator error in module] unexpected false: table initializer value must be constant, on
...
 (table $timport$0 1 1 (ref exn) (ref.as_non_null
  (ref.null noexn)
 ))

It looks like it's caused by the code described here.

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

Run the supplied bin/wasm-opt command with the seed.wast module and --translate-to-fuzz, then inspect the table-initializer path and the code discussed in the linked pull request. Done means fuzz translation no longer emits ref.as_non_null in the constant table initializer and the resulting module passes validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.