Skip to content

[cDAC] Implement CheckContext for cDAC#128503

Merged
barosiak merged 2 commits into
dotnet:mainfrom
barosiak:barosiak/CheckContext
May 23, 2026
Merged

[cDAC] Implement CheckContext for cDAC#128503
barosiak merged 2 commits into
dotnet:mainfrom
barosiak:barosiak/CheckContext

Conversation

@barosiak
Copy link
Copy Markdown
Member

Summary

Implements CheckContext in the managed cDAC. Removes the UNSUPPORTED_DbgSkipStackCheck config bypass from the native DAC.

Changes

  • Added ContextControlFlags property to the platform context interface hierarchy
  • Removed DbgSkipStackCheck config knob, dead globals, and skip logic from native DAC

Tests

  • SP in-range, out-of-range, and at-boundary validation across all 6 target architectures
  • No-control-flag early exit with verification that stack data is never queried

@barosiak barosiak self-assigned this May 22, 2026
Copilot AI review requested due to automatic review settings May 22, 2026 21:20
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR wires up DacDbiImpl.CheckContext in the managed cDAC implementation by parsing the incoming platform context buffer and (when control flags are present) validating the stack pointer against the thread’s cached stack bounds. On the native DAC side, it removes the UNSUPPORTED_DbgSkipStackCheck opt-out and related globals.

Changes:

  • Implement DacDbiImpl.CheckContext in managed code with stack-pointer range validation gated on context control flags.
  • Extend the platform context abstractions to expose ContextControlFlags for architecture-specific masking.
  • Add targeted unit tests for CheckContext and remove skip-stack-check knob/logic from the native DAC implementation.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/native/managed/cdac/tests/DacDbiImplTests.cs Adds unit tests covering CheckContext behavior for control-flag vs no-control-flag scenarios across target-arch strings.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs Implements managed CheckContext logic (reads context bytes, conditionally validates SP range, returns HRESULTs).
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/IPlatformContext.cs Adds ContextControlFlags to the public platform context interface.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/IPlatformAgnosticContext.cs Adds ContextControlFlags to the public platform-agnostic context interface.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/ContextHolder.cs Plumbs ContextControlFlags through the ContextHolder<T> wrapper.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/AMD64Context.cs Provides architecture-specific ContextControlFlags value for AMD64 contexts.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/ARMContext.cs Provides architecture-specific ContextControlFlags value for ARM contexts.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/ARM64Context.cs Provides architecture-specific ContextControlFlags value for ARM64 contexts.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/LoongArch64Context.cs Provides architecture-specific ContextControlFlags value for LoongArch64 contexts.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/RISCV64Context.cs Provides architecture-specific ContextControlFlags value for RISC-V64 contexts.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/X86Context.cs Provides architecture-specific ContextControlFlags value for x86 contexts (public type).
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/CorDbHResults.cs Adds CORDBG_E_NON_MATCHING_CONTEXT constant for managed HRESULT parity.
src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp Removes UNSUPPORTED_DbgSkipStackCheck-based bypass and dead globals; always enforces stack-range check when control flags are present.

@barosiak barosiak enabled auto-merge (squash) May 22, 2026 21:37
@barosiak barosiak merged commit dc78baa into dotnet:main May 23, 2026
125 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants