WebAssembly / WebAssembly/wabt

Issue with br labels in the JS build

Open
#915 3 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

Somehow, a module in text format like

(module
  (type $t0 (func (param i32)))
  (type $t1 (func))
  (import "env" "log" (func $log (type $t0)))
  (func $main (type $t1)
    block $B0
      block $B1
        br $B1
        i32.const 3
        call $log
      end
      i32.const 2
      call $log
    end
    i32.const 1
    call $log)
  (start 1))

becomes

(module
  (type $t0 (func (param i32)))
  (type $t1 (func))
  (import "env" "log" (func $log (type $t0)))
  (func $main (type $t1)
    block $B0
      block $B1
        br 3228196 (; INVALID ;)
        i32.const 3
        call $log
      end
      i32.const 2
      call $log
    end
    i32.const 1
    call $log)
  (start 1))

after parsing with libwabt.js. Note the invalid pointer value instead of the label on the br. Any ideas?

See: https://github.com/reklatsmasters/vscode-wasm/issues/14#issuecomment-423853330

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 WAT example through libwabt.js and compare the parsed or printed output around br $B1. Trace the text-parser and JavaScript build entry points involved in branch-label handling; done means the label is preserved in the generated text instead of becoming an invalid pointer value, with a regression test covering this input.

Written by the indexing model from the issue text.

Assessment

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