Skip to content

[cDAC][wasm] StackWalk_1 requires the Debugger contract, which WASM targets do not advertise #135034

Closed

Description

@lewing

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_WASM

On 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 (runtime cd42bb5), published with UseMonoRuntime=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

  1. dotnet-policy-service commented on Oct 1, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
    See info in area-owners.md if you want to be subscribed.

  2. dotnet-policy-service commented on Oct 1, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
    See info in area-owners.md if you want to be subscribed.

  3. added this to the 12.0.0 milestone on Oct 1, 2026
  4. locked and limited conversation to collaborators on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions