Description
Description
On WebAssembly targets, any cDAC IStackWalk walk that reaches a native-context frame throws:
ContractMissingException: Contract 'Debugger' is not advertised by the target.
This happens because StackWalk_1 calls IDebugger.GetHijackKind unconditionally for InitialNativeContext / NativeMarker states:
src/native/managed/cdac/.../Contracts/StackWalk/StackWalk_1.cs—Next(),case StackWalkState.InitialNativeContext: case StackWalkState.NativeMarker:→_target.Contracts.Debugger.GetHijackKind(ip)- same file, the x86 frame-pointer path (
GetHijackKind(handle.Context.InstructionPointer))
But the data descriptor deliberately omits the contract on WASM:
// src/coreclr/vm/datadescriptor/datadescriptor.inc
#if defined(DEBUGGING_SUPPORTED) && !defined(TARGET_WASM)
CDAC_GLOBAL_CONTRACT(Debugger, c1)
#endif // DEBUGGING_SUPPORTED && !TARGET_WASMOn a browser-wasm target the default CreateStackWalk(threadData) seeds from the Frame chain (GetContextFromFrames). That produces an InitialNativeContext almost every time, so in practice every WASM walk fails on its first Next().
Repro
- Target: CoreCLR browser-wasm, nightly
12.0.0-alpha.1.26480.103(runtimecd42bb5), published withUseMonoRuntime=false,RuntimeFlavor=CoreCLR. - Reader: cDAC built from
main@bb1b237b389. - Pause the page over CDP while managed code is running, then call
IStackWalk.CreateStackWalk(threadData)and enumerate it.
The first frame (InitialNativeContext, ip 0x1, from an InlinedCallFrame) is yielded. The next MoveNext() then throws the ContractMissingException above.
Expected
WASM has no return-address hijacking: WasmFrameHandler.HandleHijackFrame throws PlatformNotSupportedException, and the runtime never installs hijacks there. The walker should treat a missing Debugger contract as HijackKind.None on targets that don't support hijacking, or gate the call on architecture or the contract's presence.
Notes
As a workaround, Blazor-Playground/nesm registers a version-"" fallback IDebugger for unadvertised targets. It returns HijackKind.None on WASM only and throws elsewhere. With that in place, walks complete on a live browser target.
Found while validating a live IStackWalk consumer in Blazor-Playground/nesm against CoreCLR browser-wasm; related to #130988.
Activity
dotnet-policy-service commentedon Oct 1, 2026
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.
dotnet-policy-service commentedon Oct 1, 2026
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.
[cDAC][wasm] Fix stack walks and MethodDesc naming on WebAssembly (#1…