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.
ecioppettini requested dicej for a review on PR #13791.
ecioppettini requested wasmtime-core-reviewers for a review on PR #13791.
github-actions[bot] added the label wasmtime:api 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?
alexcrichton requested alexcrichton for a review on PR #13791.
alexcrichton unassigned dicej from PR #13791 fix: use unaligned reads for debug state slot values.
alexcrichton unassigned dicej from PR #13791 fix: use unaligned reads for debug state slot values.
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
alignedloads and stores are done. Can you update this method as well to remove the aligned flag? For example replacingMemFlags::trusted()withMemFlags::new().with_notrap().Also FWIW @dicej, @cfallin is on PTO this week.
ecioppettini requested wasmtime-compiler-reviewers for a review on PR #13791.
ecioppettini updated PR #13791.
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
alignedloads and stores are done. Can you update this method as well to remove the aligned flag? For example replacingMemFlags::trusted()withMemFlags::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
stackwas worth it, since both go through the same function.
: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/disasto generate a golden expectation which can theoretically be audited to say "heyalignedis indeed missing" but I think for now the test you've added is sufficient.
alexcrichton added PR #13791 fix: use unaligned reads for debug state slot values to the merge queue.
alexcrichton removed PR #13791 fix: use unaligned reads for debug state slot values from the merge queue.
:check: alexcrichton merged PR #13791.
Last updated: Jul 29 2026 at 05:03 UTC