Repository navigation
Conversation
`Store::wasm_fault` asserted that only one instance claims the faulting address. Importing a shared memory through `SharedMemory::vmimport` creates a single-memory instance that defines the same memory, so a fault in it was claimed twice and hit the assert instead of trapping. Only panic now when the address belongs to two different memories. Fixes bytecodealliance#14584
This branch has not been deployed
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 #14584.
Store::wasm_faultasserts that only one instance in the store claims the faulting address. That doesn't hold for shared memories: importing one goes throughSharedMemory::vmimport, which creates a single-memory instance that defines the same memory. So in the example from the issue, both$aand that instance report the fault, and the assert fires instead of the trap.This keeps the check but only panics when the address belongs to two different memories, by comparing the
wasm_addresseach instance reports. It doesn't comparememory_size, since a shared memory can be grown by another thread between the two reads.I added the example from the issue as
tests/misc_testsuite/threads/shared-memory-imported-oob.wast. It panics atstore.rs:2061on main and passes with this change.cargo test --test wast,cargo test --test all -- shared_memory threads trapsandcargo test -p wasmtime --libpass locally on macOS (aarch64).I used Claude Code to reproduce the bug and test the fix locally.