WebAssembly / WebAssembly/wabt

wat2wasm aborts when function has undefined reference type in parameter

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

The following module

(module
  (func (param (ref $T)) (result)
    (nop)))

aborts in both the current main HEAD and the most recent package version on Ubuntu 20.04:

pat@quercus:~/src/crack$ ../wabt/bin/wat2wasm --version
1.0.31 (git~1.0.31-22-ged0b720c)

pat@quercus:~/src/crack$ ../wabt/bin/wat2wasm --enable-function-references scratch.wat -o scratch.wasm
wat2wasm: /home/pat/src/wabt/src/wast-parser.cc:327: 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.
Aborted (core dumped)

pat@quercus:~/src/crack$ wat2wasm --version
1.0.27

pat@quercus:~/src/crack$ wat2wasm --enable-function-references scratch.wat -o scratch.wasm
wat2wasm: ./src/wast-parser.cc:279: void wabt::{anonymous}::ResolveTypeName(const wabt::Module&, wabt::Type&, wabt::Index, const std::unordered_map<unsigned int, std::__cxx11::basic_string<char> >&): Assertion `type_index != kInvalidIndex' failed.
Aborted (core dumped)

If (ref $T) is replaced with $T, I get an error message. Not a huge problem, just a little confusing.

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 with the reproducing module and the wat2wasm command using --enable-function-references, then inspect ResolveTypeName in src/wast-parser.cc, which appears in the reported assertion. Done means the undefined (ref $T) parameter produces a normal error like the $T case instead of aborting; no test file is named in the report.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.