Skip to content

component(err-ctx): trap on a misaligned pointer - #14626

Merged
rvolosatovs merged 1 commit into
bytecodealliance:mainfrom
rvolosatovs:fix/err-ctx-align
Oct 9, 2026
Merged

rvolosatovs merged 1 commit into
bytecodealliance:mainfrom
rvolosatovs:fix/err-ctx-align

Conversation

@rvolosatovs

Copy link
Copy Markdown
Member

error-context.debug-message bounds-checked the guest-provided destination pointer for the string's (ptr, len) pair, but not its alignment, and then wrote the pair via
<str as Lower>::linear_lower_to_memory, which debug_assert!s that the offset is 4-byte aligned. A guest passing an in-bounds but misaligned pointer could therefore panic the host in debug builds, while release builds performed the unaligned write.

Check the pointer's alignment before lowering and trap with "invalid debug message pointer: not aligned", the same way the stream/future read and write paths in this file report misaligned pointers.

`error-context.debug-message` bounds-checked the guest-provided
destination pointer for the string's `(ptr, len)` pair, but not its
alignment, and then wrote the pair via
`<str as Lower>::linear_lower_to_memory`, which `debug_assert!`s that
the offset is 4-byte aligned. A guest passing an in-bounds but
misaligned pointer could therefore panic the host in debug builds,
while release builds performed the unaligned write.

Check the pointer's alignment before lowering and trap with
"invalid debug message pointer: not aligned", the same way the
stream/future read and write paths in this file report misaligned
pointers.

Assisted-by: claude:claude-opus-5-5
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
@rvolosatovs
rvolosatovs requested a review from a team as a code owner October 9, 2026 16:03
@rvolosatovs
rvolosatovs requested review from dicej and removed request for a team October 9, 2026 16:03
@rvolosatovs
rvolosatovs enabled auto-merge October 9, 2026 16:03
@rvolosatovs
rvolosatovs added this pull request to the merge queue Oct 9, 2026
Merged via the queue into bytecodealliance:main with commit a8d33e5 Oct 9, 2026
53 checks passed
@rvolosatovs
rvolosatovs deleted the fix/err-ctx-align branch October 9, 2026 16:37
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