Spec interpreter/implementation discrepancy - a local with an invalid type and 0 count
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Active
- Tech stack
- wasm
- Domain
- compilers
Research direction
Start with the linked code-section specification and the reference interpreter, then reproduce the behavior using foo.wasm and compare it with V8, SpiderMonkey, and Wasmtime. Determine whether a zero-count local's type should be validated or discarded, and document the agreed specification or implementation outcome.
Written by the indexing model from the issue text.
Description
My understanding of the definition of the code section in the online specification is that if an entry in locals has n=0 count that it's discarded and not represented in the AST of a module. This means that the corresponding local's type is parsed, but not validated. The reference interpreter implements this behavior and for this input:
(module binary
"\00asm\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section: 1 type
"\03\02\01\00" ;; Function section: 1 function
"\0a\07" ;; code section, 7 bytes
"\01" ;; 1 function body
"\05" ;; body size, 5 bytes
"\01" ;; 1 locals entry
"\00" ;; count: 0
"\63\01" ;; type: (ref null 1) -- not a valid type index
"\0b" ;; end
)
the spec interpreter passes. This same module (foo.wasm) does not validate in V8, SpiderMonkey, or Wasmtime, however. These engines all validate the local's type and reject the module saying that it's out-of-bounds.
I wanted to raise this as an issue to see if others have thoughts about this. I don't have a preference for how exactly to go here myself.
- Dominant language
- WebAssembly
- Stars
- 3.5k
- Forks
- 539
- Avg merge
- 10h 24m
- Merged PRs (30d)
- 11
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from WebAssembly/spec
-
Difficulty 4/5 3-5 days Newbie friendliness 54/100
WebAssembly/spec#2265 ·
Maintainers usually reply within 1 day
-
[js-api] A mutable global import allocates a const global before LinkErrorPossibly taken @chicoxyzzy claimed this 1 day ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 58/100
WebAssembly/spec#2253 ·
Maintainers usually reply within 1 day
-
[spectec] Wasm 1.0: `$instantiate` missing premisesPossibly taken @rossberg claimed this 27 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
WebAssembly/spec#2245 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
WebAssembly/spec#2235 · 9 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
WebAssembly/spec#2196 ·
Maintainers usually reply within 1 day
All issues in WebAssembly/spec
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/TypeScript#64661 ·
Maintainers usually reply within 1 day
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Sim20004/teapot-lang#248 ·