Stream: git-wasmtime

Topic: wasmtime / PR #15365 Guest debugging: fix PC lookups to f...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 05:07):

cfallin opened PR #15365 from cfallin:fix-15332 to bytecodealliance:main:

When guest debugging is enabled, a module used within a given store gets a private copy of the code. We call the original code "engine code" and the maybe-private copy "store code". We have newtypes around PCs for both (EngineCodePC and StoreCodePC). When guest debugging is disabled, we still call the actually executing copy the "store code"; it just happens to alias the engine code instead (no private copy).

Various parts of the runtime do lookups based on observed PCs in frames (e.g., trap code loop, GC stackmap lookup, and exception-handler lookup).

I wrote most of this code when the invariant was still that all code actually running in a given store would be "store code". Late in the implementation of guest debugging, I discovered it would not be easily possible to have a private copy of some trampolines, but that they were "store-invariant" (no breakpoint patching was possible since no guest Wasm program points were present in the trampolines), so it was fine to run the canonical/shared engine copy.

Unfortunately, the idea that we look up "store PCs" only is in conflict with this, and we thus would not find e.g. exception handlers in store-invariant trampolines (see #15332 for an example).

This PR generalizes things a bit: we can look up both engine PCs and store PCs in the per-store registry, and we can get a sum-type result that can represent a PC found in either kind of copy. We can look up metadata and derive exception-handler PCs from either kind of hit. We then use this in all the relevant places that we do PC lookups.

Fixes #15332.

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please review the Bytecode Alliance's AI tool usage policy at
https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.md

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 05:07):

cfallin requested dicej for a review on PR #15365.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 05:07):

cfallin removed the review request for wasmtime-core-reviewers from PR #15365.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 05:07):

cfallin requested wasmtime-core-reviewers for a review on PR #15365.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 05:08):

cfallin removed the review request for dicej from PR #15365.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 05:08):

cfallin requested alexcrichton for a review on PR #15365.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 07:44):

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

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 18:55):

:memo: alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 18:55):

:speech_balloon: alexcrichton created PR review comment:

Could it make sense to maybe return (&CodeMemory, usize) here instead of StoreOrEngineCodeAndOffset? It naively seems like all the queries basically bottom out in &CodeMemory

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 18:55):

:speech_balloon: alexcrichton created PR review comment:

Alternatively, would it make sense to maybe call this code_memory_by_pc?

And, additionally, could store_code_by_pc be made private? it seems like all users of it are now gone with the migration to using this function. (maybe this means the preexisting function could be replaced by code_memory_by_pc?)

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 18:55):

:speech_balloon: alexcrichton created PR review comment:

I'm always wary of adding more storage here since this is on the hot path for instantiation. Cloning this in a multi-tenant situation could be a hotly-contended clone of an Arc which has historically been able to show up in profiles (and this is a second clone with the one above). I'm also wary of adding always-on functionality which is only needed when debugging.

Would it make sense to maybe have this be Option<Arc<EngineCode>> and only set this if StoreCode above is a store-local copy?


Last updated: Nov 19 2026 at 20:05 UTC