WebAssembly / WebAssembly/wabt
wat2wasm: data section memory index
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 8.1k
- Forks
- 827
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 18
Description
Take the following code:
(module
(memory $n 1)
(memory $m 1)
(data (memory $m) (i32.const 0))
)
The data section has bytes:
; data segment header 0
0000012: 02 ; segment flags
0000013: 41 ; i32.const
0000014: 00 ; i32 literal
0000015: 0b ; end
As you can see from spec, flag == 2 expects memory index u32, but wabt omits it.
If you try to compile that code in JS, you'll see the error:
CompileError: WebAssembly.Module(): invalid memory index 65 for data section (having 2 memories) @+18
Adding memory index after segment flag solves the issue (watr has that fixed).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example with the wat2wasm entry point and inspect the emitted data section bytes for the segment using memory $m. Compare the encoding with the WebAssembly data-section specification and validate the result by compiling the output in JavaScript; done means the memory index is emitted and the module compiles successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, wasm
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100