cfallin opened PR #12575 from cfallin:debug-frames-miri to bytecodealliance:main:
The fix to
vm_store_contextprovenance inrecord_unwind/unwindis a little weird to me. I was seeing mut access to thevm_store_contextviastore.vm_store_context_mut()inrecord_unwind(before this diff) then access via the previously saved raw pointer in theCallThreadState, which was registered as invalid and I believe is indeed invalid. This was only manifesting when settingConfig::guest_debug, even without the frame-handle accesses added here. I didn't dig into the exact diff in codegen or runtime behavior that caused this but in any case, accessingvm_store_contextvia these two different paths (with one mut) appears to be unsound in any case. The fix here is to set the unwind state via the raw pointer inCallThreadStatesince that's the only path that the subsequentunwindhas access to.Unrelated but useful:
ci/miri-provenance.test.shnow acceptsMIRI_RUST_VERSION=+nightlyor whatnot, which is nice for running locally (I keepstableas my default toolchain).Stacked on top of #12566 (only last commit is new).
cfallin requested alexcrichton for a review on PR #12575.
cfallin requested wasmtime-compiler-reviewers for a review on PR #12575.
cfallin requested wasmtime-default-reviewers for a review on PR #12575.
cfallin requested wasmtime-core-reviewers for a review on PR #12575.
cfallin updated PR #12575.
cfallin edited PR #12575:
The fix to
vm_store_contextprovenance inrecord_unwind/unwindis a little weird to me. I was seeing mut access to thevm_store_contextviastore.vm_store_context_mut()inrecord_unwind(before this diff) then access via the previously saved raw pointer in theCallThreadState, which was registered as invalid and I believe is indeed invalid. This was only manifesting when settingConfig::guest_debug, even without the frame-handle accesses added here. I didn't dig into the exact diff in codegen or runtime behavior that caused this but in any case, accessingvm_store_contextvia these two different paths (with one mut) appears to be unsound in any case. The fix here is to set the unwind state via the raw pointer inCallThreadStatesince that's the only path that the subsequentunwindhas access to.Unrelated but useful:
ci/miri-provenance.test.shnow acceptsMIRI_RUST_VERSION=+nightlyor whatnot, which is nice for running locally (I keepstableas my default toolchain).
cfallin updated PR #12575.
cfallin updated PR #12575.
alexcrichton submitted PR review:
Thanks! Do you think it'd be worth running through anything else in the debug API as well? Or does getting a module more-or-less exercise everything?
alexcrichton created PR review comment:
Another way you can run this script is
rustup run nightly ./ci/miri-provenance.test.sh ...although usingMIRI_RUST_VERSION=+nightlyworks here too just as well
github-actions[bot] added the label wasmtime:api on PR #12575.
cfallin updated PR #12575.
cfallin submitted PR review.
cfallin created PR review comment:
Ah, I had no idea -- thanks! Removed my ad-hoc env var and added a comment to this script instead noting this trick.
cfallin commented on PR #12575:
Getting the current module exercises almost everything (frame-walking, getting metadata, reading raw vmctx and converting back to proper borrow of instance, etc) but I added a few more reads for good measure. Thanks!
cfallin has enabled auto merge for PR #12575.
cfallin added PR #12575 miri: add guest-debugging, including frame accesses. to the merge queue
cfallin edited PR #12575:
The fix to
vm_store_contextprovenance inrecord_unwind/unwindis a little weird to me. I was seeing mut access to thevm_store_contextviastore.vm_store_context_mut()inrecord_unwind(before this diff) then access via the previously saved raw pointer in theCallThreadState, which was registered as invalid and I believe is indeed invalid. This was only manifesting when settingConfig::guest_debug, even without the frame-handle accesses added here. I didn't dig into the exact diff in codegen or runtime behavior that caused this but in any case, accessingvm_store_contextvia these two different paths (with one mut) appears to be unsound in any case. The fix here is to set the unwind state via the raw pointer inCallThreadStatesince that's the only path that the subsequentunwindhas access to.
github-merge-queue[bot] removed PR #12575 miri: add guest-debugging, including frame accesses. from the merge queue
cfallin updated PR #12575.
cfallin commented on PR #12575:
@alexcrichton pinging for re-review here -- another miri test failure (not part of the Pulley provenance test) has pushed me back toward another approach that involves re-deriving the raw
VMStoreContextpointer inCallThreadStatewhen setting up unwind state, for provenance reasons; this avoids action-at-a-distance failures where any mutation on the store in some path can potentially invalidate provenance.
cfallin updated PR #12575.
cfallin updated PR #12575.
cfallin commented on PR #12575:
(There's still a failure on s390x only that I suspect is an endianness issue when running Pulley + guest-debug instrumentation -- will take a look)
alexcrichton submitted PR review:
Looks reasonable to me yeah :+1:
cfallin commented on PR #12575:
A little more detail: Pulley on s390x with guest-debug enabled (which hasn't been tested before -- only native s390x with guest-debug) is generating a big-endian vector store in the CLIF to compile to Pulley, which Cranelift's Pulley backend doesn't support. That's a nontrivial bit of implementation (lane swapping, etc). I'll instead refactor the instrumentation to work as e.g. object fields do, always little endian, in a separate PR.
cfallin commented on PR #12575:
s390x fix in #12585; will rebase on that once merged.
alexcrichton submitted PR review:
Looks reasonable to me yeah :+1:
cfallin updated PR #12575.
cfallin has enabled auto merge for PR #12575.
cfallin edited a comment on PR #12575:
s390x fix in #12585; will
rebase on thatmerge that in once merged.
cfallin added PR #12575 miri: add guest-debugging, including frame accesses. to the merge queue
cfallin merged PR #12575.
cfallin removed PR #12575 miri: add guest-debugging, including frame accesses. from the merge queue
Last updated: Feb 24 2026 at 04:36 UTC