Stream: git-wasmtime

Topic: wasmtime / PR #13791 fix: use unaligned reads for debug s...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 01 2026 at 15:09):

ecioppettini opened PR #13791 from ecioppettini:fix/guest-debug-unaligned-read to bytecodealliance:main:

I randomly ran into: misaligned pointer dereference: address must be a multiple of 0x8 but is ... when using the guest debugging api to inspect the frame. I couldn't find an issue for it, but the change is so small that I decided to just open a PR directly.

The issue seems to be that debug frames are packed without any padding, but on the read side it's assuming natural alignment. Then an i64 can end up in a 4-byte-aligned address if there is an i32 before it, for example.

I think the 4-byte types don't necessarily need this change, and is unlikely it will change, but I just switched all of them for consistency.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 01 2026 at 15:09):

ecioppettini requested dicej for a review on PR #13791.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 01 2026 at 15:09):

ecioppettini requested wasmtime-core-reviewers for a review on PR #13791.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 01 2026 at 16:32):

github-actions[bot] added the label wasmtime:api on PR #13791.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 01 2026 at 16:36):

dicej commented on PR #13791:

@cfallin This looks reasonable to me, but I haven't been following your recent debugging work closely. Would you mind taking a look?

view this post on Zulip Wasmtime GitHub notifications bot (Jul 01 2026 at 18:20):

alexcrichton requested alexcrichton for a review on PR #13791.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 01 2026 at 18:20):

alexcrichton unassigned dicej from PR #13791 fix: use unaligned reads for debug state slot values.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 01 2026 at 18:20):

alexcrichton unassigned dicej from PR #13791 fix: use unaligned reads for debug state slot values.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 01 2026 at 18:20):

alexcrichton commented on PR #13791:

Locals look like they're packed, yes, so I believe it's correct to use unaligned loads/stores here, and I think it's fine to do unaligned for all types as opposed to just the 64-bit-and-larger types.

Looking a bit further into this, however, the CLIF I believe is also invalid because aligned loads and stores are done. Can you update this method as well to remove the aligned flag? For example replacing MemFlags::trusted() with MemFlags::new().with_notrap().

Also FWIW @dicej, @cfallin is on PTO this week.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 01 2026 at 18:56):

ecioppettini requested wasmtime-compiler-reviewers for a review on PR #13791.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 01 2026 at 18:56):

ecioppettini updated PR #13791.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 01 2026 at 19:06):

ecioppettini commented on PR #13791:

Locals look like they're packed, yes, so I believe it's correct to use unaligned loads/stores here, and I think it's fine to do unaligned for all types as opposed to just the 64-bit-and-larger types.

Looking a bit further into this, however, the CLIF I believe is also invalid because aligned loads and stores are done. Can you update this method as well to remove the aligned flag? For example replacing MemFlags::trusted() with MemFlags::new().with_notrap().

Also FWIW @dicej, @cfallin is on PTO this week.

Hi, thanks for the feedback. I did push that change.

Also changed this method seems it seems like a mirror of the other one (I'm not familiar with the code, so I may be wrong).

I don't really know how to test this (if it's even possible).

Locals look like

It also applies to the operand stack, by the way. I wasn't sure if adding a test reaching the error through stack was worth it, since both go through the same function.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 01 2026 at 19:09):

:thumbs_up: alexcrichton submitted PR review:

Oh good catch on the other function, thanks! And yeah I think the existing test here is fine to cover both. CLIF tests can in theory be added to tests/disas to generate a golden expectation which can theoretically be audited to say "hey aligned is indeed missing" but I think for now the test you've added is sufficient.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 01 2026 at 19:09):

alexcrichton added PR #13791 fix: use unaligned reads for debug state slot values to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 01 2026 at 19:33):

alexcrichton removed PR #13791 fix: use unaligned reads for debug state slot values from the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 01 2026 at 19:33):

:check: alexcrichton merged PR #13791.


Last updated: Jul 29 2026 at 05:03 UTC