Skip to content

CABI: trap on misaligned waitable-set.{wait,poll} ptr - #741

Merged
lukewagner merged 1 commit into
WebAssembly:mainfrom
rvolosatovs:fix/unpack-event-ptr
Oct 13, 2026
Merged

lukewagner merged 1 commit into
WebAssembly:mainfrom
rvolosatovs:fix/unpack-event-ptr

Conversation

@rvolosatovs

Copy link
Copy Markdown
Contributor

unpack_event stored the two i32 event payloads at the guest-supplied ptr through store, whose alignment and bounds checks are assertions rather than traps. A misaligned or out-of-bounds ptr thus raised an AssertionError in the reference interpreter instead of trapping, and the prose said nothing.

Trap unless ptr is 4-byte-aligned and ptr + 8 is within memory, matching the checks lower_flat_values applies to an out-param pointer and what Wasmtime already does. Document this in CanonicalABI.md and the Explainer, whose description of waitable-set.wait wrongly called payload-addr 8-byte-aligned: the payload is two contiguous i32s, so 4-byte alignment is all the ABI requires.

unpack_event stored the two i32 event payloads at the guest-supplied `ptr`
through store, whose alignment and bounds checks are assertions rather than
traps. A misaligned or out-of-bounds `ptr` thus raised an AssertionError in
the reference interpreter instead of trapping, and the prose said nothing.

Trap unless `ptr` is 4-byte-aligned and `ptr + 8` is within memory, matching
the checks lower_flat_values applies to an out-param pointer and what
Wasmtime already does. Document this in CanonicalABI.md and the Explainer,
whose description of waitable-set.wait wrongly called `payload-addr`
8-byte-aligned: the payload is two contiguous i32s, so 4-byte alignment is
all the ABI requires.

Assisted-by: claude:claude-fable-5-1
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
@lukewagner

Copy link
Copy Markdown
Member

Thanks!

@lukewagner
lukewagner merged commit 2e7895c into WebAssembly:main Oct 13, 2026
1 check 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.

2 participants