WebAssembly / WebAssembly/wabt

Wrong type error when validating globals with gc proposal features

Open
#2,407 0 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

In the GC proposal, it allows using previous global value as an initializer expression.

Screenshot 2024-04-02 at 7 03 26 PM

Therefore, following wasm module is a valid module in the GC proposal.

;; global.wat
(module (global i32 (i32.const 0)) (global i32 (global.get 0)))

I run the module with the reference interpreter in the gc proposal, and it passes the validation.

$ gc/interperter/wasm global.wat
// terminates normally

As the reference interpreter also includes function references and tail call proposals, I enable all of them and run wat2wasm, but it raises type error.

$ wabt/bin/wat2wasm --enable-function-references --enable-tail-call --enable-gc global.wat
global.wat:1:60: error: initializer expression can only reference an imported global
(module (global i32 (i32.const 0)) (global i32 (global.get 0)))
                                                           ^

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 using global.wat and the --enable-function-references, --enable-tail-call, and --enable-gc flags. Trace the validation path for global initializer expressions and confirm that the valid module is accepted while invalid initializers remain rejected.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
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.