Stream: git-wasmtime

Topic: wasmtime / PR #14655 Debugging: explicitly null-initializ...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 10 2026 at 05:09):

cfallin opened PR #14655 from cfallin:fix-debug-uninit-non-nullable-gc-ref to bytecodealliance:main:

Right now, before a non-nullable local is in-scope semantically (from the bytecode's point of view), if guest debugging is enabled, that local's value is (i) still accessible via debug APIs, and (ii) still exposed as a GC root.

This is a problem, because non-nullable-ref-typed locals are compiled with the first def (write) to that local at the point that the local enters scope, not at the start of the function. So if a GC occurs, or if a debug API observes the value, early on (say at a breakpoint or when single-stepping before the initial def point), it will observe garbage.

This PR adds an explicit init for all such locals: they are null internally in the debug state slot, even if the Wasm-level type is non-nullable. This satisfies the GC when tracing values, and also provides something for the debug API to return.

The alternative would be to represent their absence (not-yet-in-scope status) explicitly, but I figured this would be much more complicated: it would mean we would need a locals-valid bitmask at any given PC for the debug API to read out. The debug API is not defining the actual Wasm semantic model, it is just presenting a shadow view of the world, so (IMHO) it's fine for that shadow view to have a (well-defined) simplification in this case. In essence, we are lowering the more complicated (non-nullable) type to a nullable type, initially null, in the debug state.

<!--
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 (Oct 10 2026 at 05:09):

cfallin requested alexcrichton for a review on PR #14655.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 10 2026 at 05:09):

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

view this post on Zulip Wasmtime GitHub notifications bot (Oct 10 2026 at 05:09):

cfallin requested wasmtime-compiler-reviewers for a review on PR #14655.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 10 2026 at 05:18):

cfallin commented on PR #14655:

Another alternative could be to have an explicit undefined sentinel value that a VMGcRef can take on, and that the GC ignores (and that the debug API would translate to an appropriate Option probably). This is analogous to what SpiderMonkey does -- lexically-scoped locals have a "hole" MagicValue. Happy to go that way if that's what folks want, it just touches more -- @fitzgen for thoughts maybe?

view this post on Zulip Wasmtime GitHub notifications bot (Oct 10 2026 at 18:10):

alexcrichton requested fitzgen for a review on PR #14655.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 10 2026 at 18:10):

alexcrichton unassigned alexcrichton from PR #14655 Debugging: explicitly null-initialize non-nullable locals' state slots..


Last updated: Oct 11 2026 at 02:20 UTC