Repository navigation
Fix/shared memory export waiters - #65
Merged
Merged
Conversation
ncruces
force-pushed
the
fix/shared-memory-export-waiters
branch
3 times, most recently
from
October 12, 2026 12:35
292f4cd to
1aafc5b
Compare
Owner
|
I rebased and fixed some formatting issues, just to make it easier to review. |
ncruces
force-pushed
the
fix/shared-memory-export-waiters
branch
2 times, most recently
from
October 15, 2026 18:18
2e1f175 to
4f6c22e
Compare
Owned shared memory modules exported a Memory view by casting the module's []byte to *wasmMemory, but Waiters() was generated on that slice alias and referenced m.waiters, which does not exist on []byte. Generated packages then failed to compile (e.g. m.waiters undefined). Model shared owned memory as a wasmMemory struct holding *[]byte and *sync.Map, and return a composite literal from memory exports so Waiters() is wired to the module's waiter map. Add a minimal shared_export regression fixture and test; refresh provided_helper golden output from translate.
ncruces
force-pushed
the
fix/shared-memory-export-waiters
branch
from
October 16, 2026 13:18
4f6c22e to
3fe220e
Compare
Rather than special casing shared memory, make wasmMemory a struct that holds the owned memory (and waiters), and embed it in Module. Field promotion keeps m.memory/m.waiters working unchanged, Slice/Grow operate on the embedded fields, and the memory export is &m.wasmMemory. This gives shared and non-shared owned memory the same shape, and removes the (*[]byte)(m) casts.
ncruces
force-pushed
the
fix/shared-memory-export-waiters
branch
from
October 16, 2026 13:34
3fe220e to
9e39608
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #64
Summary
memory. The generator used to cast the module[]byteto*wasmMemoryand emitWaiters()on that slice alias, which referencesm.waitersand does not compile.wasmMemoryis a struct with*[]byteand*sync.Map. The export returnswasmMemory{memory: &m.memory, waiters: m.waiters}soWaiters()uses the module waiter map.testdata/regression/shared_export(WAT, WASM, golden Go) andTest_regression_shared_export. Cover this fixture withgo test -args -unsafe; defaultgo testskips its translate golden.Problem
WAMR multi-thread samples (and similar modules) with
(memory … shared)and(export "memory")produce output that failsgo build, for examplem.waiters undefined (type *wasmMemory has no field or method waiters)on the memory export.