Repository navigation
Check memory64 addr+offset overflow in wasm2c store/atomic/simd ops - #2790
Merged
Merged
Conversation
sbc100
reviewed
Jul 7, 2026
Contributor
Author
|
Pushed the helper. One note on output: the old emitters disagreed on the literal suffix for the 32-bit path (loads wrote Re-ran the checks after the refactor: wasm2c tests 265/265, unit tests 134/134, clang-format clean. The memory64 repro (store at 0xFFFFFFFFFFFFFFF0 with offset=16) still traps instead of wrapping to guest address 0. |
sbc100
approved these changes
Jul 8, 2026
Member
|
@shravanrn can you take another look? |
shravanrn
force-pushed
the
memory64-store-offset-overflow
branch
from
July 8, 2026 20:11
a33bd27 to
71a8219
Compare
sbc100
enabled auto-merge (squash)
July 8, 2026 20:12
sbc100
disabled auto-merge
July 8, 2026 23:56
Contributor
Author
|
Thanks for the reviews and the merge. The helper ended up tidier than the original anyway. |
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.
Comparing wasm2c output either side of 4bedf7c ("check address + offset addition for memory64"):
That commit only converted
CWriter::Write(const LoadExpr&). For an i64 memory the store still adds the static offset with a wrapping+, and so do the SIMD lane/splat/zero and atomic emitters.How I hit it: memory64 module,
i64.store offset=16at address0xFFFFFFFFFFFFFFF0. The sum overflows u64 to 0, the generatedRANGE_CHECKsees an in-range address, and the write lands at guest address 0. Per the spec that access should trap; the load form already does after 4bedf7c.Applied the same
checked_add_u64guard toStoreExpr,SimdLoadLaneExpr,SimdStoreLaneExpr,LoadSplatExpr,LoadZeroExpr,AtomicLoadExpr,AtomicStoreExpr,AtomicRmwExprandAtomicRmwCmpxchgExprforis_64memories. The 32-bit output is byte for byte unchanged. The wasm2c spec tests (memory64, threads, simd) still pass.