WebAssembly / WebAssembly/wabt

Typed funcref: handle unbound type names in validation

Open
#1,890 2 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

An example program like the following should fail during validation:

;;; TOOL: wat2wasm
;;; ARGS: --enable-function-references
;;; ERROR: 1
(module
  (func (param $f (ref $x)) (result f32))
  )
(;; STDERR ;;;
;;; STDERR ;;)

Because the ref $x is unbound.

Right now this will trigger an assertion failure:

  +wat2wasm: ../../../src/wast-parser.cc:283: void wabt::(anonymous namespace)::ResolveTypeName(const wabt::Module &, wabt::Type &, wabt::Index, const std::unordered_map<uint32_t, std::string> &): Assertion `type_index != kInvalidIndex' failed.

which is erroring too soon. Instead, the representation of parsed types should probably include a Var so that the name lookup can be done in validation, when the entire module state is built up already.

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 in src/wast-parser.cc at ResolveTypeName and use the inline wat2wasm example as the regression case. Trace how parsed type names are represented and resolved before validation; done means an unbound ref name produces a validation error instead of triggering the assertion.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.