[js-api] A mutable global import allocates a const global before LinkError
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 58/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- wasm
- Domain
- compilers
Research direction
Start with the JS API “read the imports” algorithm and trace its interaction with module_instantiate and global_alloc; compare it with the old ExecuteModule path described in the issue. Done means mismatched mutable/const global imports throw LinkError before allocation, while successful fresh-value allocation uses the import mutability.
Written by the indexing model from the issue text.
Description
In read the imports, a global import ignores mut:
If externtype is of the form global mut valtype,
If v implements Global,
Let globaladdr be v.[[Global]].
Otherwise,
…
Let (store, globaladdr) be global_alloc(store, const valtype, value).
Set the surrounding agent's associated store to store.
module_instantiate still rejects a mismatch, so the link fails. The store update happens first.
- A
varimport whose value is not aGlobalallocates aconstglobal, then the type check fails. That global stays in the store and is not exposed to JavaScript. - A
constimport of avarGlobalreuses that global and fails the same check. Nothing new is allocated.
A number can only successfully import a const global, so the allocation on the var path is always discarded.
This showed up while sharing the reader with ESM integration (discussion). The old ExecuteModule path threw LinkError before allocation when mut was var and the value was not a Global, and when a const import was a var Global. Matching the JS API drops those checks.
Suggested change, before global_alloc:
- If the value is not a
Globalandmutisvar, throw aLinkError. - If the value is a
Global,mutisconst, and that global isvar, throw aLinkError. - Otherwise allocate with the import's
mut. For a fresh value that is onlyconst.
- 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
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
WebAssembly/spec#2258 · 4 comments · 1 reaction ·
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
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
I-prioritize needs-triage regression-from-stable-to-beta T-lang
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
rust-lang/rust#163830 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
rubys/roundhouse#444 ·
Maintainers usually reply within 1 day
-
IntrinsicLowering::LowerCTPOP runs into assertion with LLVM 23Possibly taken A pull request linked to this issue is open or already merged. Opencrash llvm:codegen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
llvm/llvm-project#229064 ·
Maintainers usually reply within 1 day
-
area:lowering kind:bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day