WebAssembly / WebAssembly/wabt

Incorrect Validation for Element Segment Initialization

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

wasm-interp does not correctly handle element segment initialization using global.get for non-imported globals.

Test case

program.wasm
program.wasm.txt

Environment
  • OS: Ubuntu 20.04
  • CPU: amd64
  • WABT version: 1.0.36
  • Commands:
./wasm-interp --enable-all --run-export=main ./program.wasm
Actual behavior

/path/to/wabt/bin/wasm-validate --enable-all --run-export=main /path/to/test/program.wasm
error: initializer expression can only reference an imported global

Expected Behavior

Element segment offset expressions should be able to reference both imported and non-imported globals. The module should pass validation without errors.

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 by reproducing the issue with program.wasm using wasm-interp --enable-all --run-export=main and inspect the related wasm-validate behavior. Confirm that the element segment offset expression accepts global.get for a non-imported global, that validation passes, and that the module can run its main export without the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
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.