Skip to content

Fix memory64: u64 offset decoding and address handling#22

Merged
chaploud merged 1 commit intomainfrom
fix/e2e-memory64-failures
Apr 2, 2026
Merged

Fix memory64: u64 offset decoding and address handling#22
chaploud merged 1 commit intomainfrom
fix/e2e-memory64-failures

Conversation

@chaploud
Copy link
Copy Markdown
Contributor

@chaploud chaploud commented Apr 2, 2026

Summary

  • Fix memory64 u64 LEB128 offset decoding across decoder, validator, predecoder, and VM
  • Fix memory64 i64 address popping for all memory operations (load/store/atomic/SIMD)
  • Add overflow detection in Memory.read/write for memory64 effective address computation

Fixes CI failures introduced by wasm-tools 1.246.1 bump (PR #21) which correctly encodes memory64 offsets as u64.

Test plan

  • zig build test — Mac + Ubuntu (0 fail, 0 leak)
  • Spec tests — 62,263/62,263 (100%, 0 skip) — Mac + Ubuntu
  • E2E tests — 795/795 Mac, 792/792 Ubuntu (3 new tests from updated wasmtime)
  • Real-world compat — 50/50 Mac + Ubuntu
  • FFI tests — 68/68 Mac + Ubuntu
  • Minimal build — Mac + Ubuntu

memory64 spec requires u64 LEB128 offsets in memarg and i64 stack
addresses, but zwasm was using u32 throughout. This caused CI failures
after wasm-tools 1.246.1 started encoding memory64 offsets correctly.

Changes:
- memory.zig: read/write accept u64 offset+address with overflow detection
- module.zig: validateBodyEnd reads offsets as u64 (body scanner)
- validate.zig: conditional u64/u32 offset based on memAddrType(memidx)
- predecode.zig: read u64 offset, bail to interpreter if > u32_max
- vm.zig: readMemarg returns u64 offset for memory64; all load/store/
  atomic/SIMD memory ops pop i64 address for memory64 memories

Fixes E2E: memory64_offsets (decode overflow), memory64_threads
(atomic OOB with large addresses). Spec 62263/0/0, E2E 795/0.
@chaploud chaploud merged commit 4121ebd into main Apr 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant