Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typed funcref: handle unbound type names in validation #1890

Open
takikawa opened this issue Apr 5, 2022 · 2 comments
Open

Typed funcref: handle unbound type names in validation #1890

takikawa opened this issue Apr 5, 2022 · 2 comments

Comments

@takikawa
Copy link
Contributor

takikawa commented Apr 5, 2022

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.

@zherczeg
Copy link
Contributor

I am new here, and may misunderstand something but the IsModuleField(PeekPair()) while loop completes in WastParser::ParseModuleFieldList before calling ResolveFuncTypes(module, errors_), so all types should be available.

https://github.com/WebAssembly/wabt/blob/main/src/wast-parser.cc#L1165

I try to figure out what is happening here.

@zherczeg
Copy link
Contributor

#1892 eliminates the assert issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants