ReviewOS

zig-utils/zig-js

Wasm: synchronize shared writes with relocating memory growth

#425
Closed chris opened this 9 days ago ·
9 days ago

Roadmap: #134 GC parent: #144

Exact main run 29803416991 exposed a no-GIL TSan race between ordinary shared TypedArray writes and the copy performed by relocating WebAssembly Memory.grow. Relocating growth now observes shared bytes through synchronized semantics while preserving old aliases and leaving exclusive non-shared paths unchanged.

Acceptance

  • Define a per-memory synchronization contract without reintroducing the JS GIL.
  • Make relocation race-free while preserving exact contents and historical aliases.
  • Keep exclusive ArrayBuffer and Wasm memory paths unchanged.
  • Preserve detach, generation, and publication ordering.
  • Pass the focused overlap case repeatedly under TSan plus Debug and ReleaseSafe semantics.
  • Add a regression covering contents, lengths, historical aliases, and teardown.
  • Reconcile an unsuperseded exact main run.

Completed by 7ed9d280; exact-main run 29806223245 passed 43/43 jobs.

9 days ago

Root fix pushed directly to main in 7ed9d280. Host-observed ordinary Wasm memory now asks the JS embedding to lock the current ArrayBuffer only around the old-to-fresh relocation copy. It unlocks before fresh-wrapper allocation/publication; the existing detach step reacquires the same buffer lock before the old slab is freed. Unrelated memories, shared non-moving slabs, and pure-Wasm/non-host growth retain their existing paths. Evidence on Zig 0.17.0-dev.1426: exact mc-grow-wasm-relocating-grow.js passes Debug (32.8 s), ReleaseSafe (0.17 s), and TSan (220.4 s); the new callback/publication unit passes Debug, ReleaseSafe, and TSan (3/3, zero leaks). Fresh exact main run is pending.

9 days ago

Closed against exact main commit e3fdc52385204c75fe6ae5c64d48dae6e5ede418: Actions run 29806223245 completed successfully with all 43 jobs terminal and no failures.

Sign in to comment on this issue.