Skip to content

Add cDac contract for ResolveFrameHelper#129261

Open
leculver wants to merge 5 commits into
dotnet:mainfrom
leculver:leculver/cdac-resolve-helper-frame
Open

Add cDac contract for ResolveFrameHelper#129261
leculver wants to merge 5 commits into
dotnet:mainfrom
leculver:leculver/cdac-resolve-helper-frame

Conversation

@leculver

Copy link
Copy Markdown
Contributor

cDac does not support ResolveFrameHelper, leading to broken stacks/missed roots when it's on the callstack.

@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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 extends the cDAC stack-walking contracts to understand ResolveHelperFrame (a resumable TransitionFrame used by interface resolve helper dispatch), so stack walking can correctly step past it and derive a correct thread context (including argument registers) from its TransitionBlock.

Changes:

  • Add a new cDAC data type/descriptor for ResolveHelperFrame (native descriptor + managed data adapter) and wire it into stack-walk frame classification/resumable handling.
  • Update platform frame handlers to support updating context from a raw TransitionBlock pointer and to update argument registers for ResolveHelperFrame where appropriate (AMD64/ARM64).
  • Extend unit test infrastructure and stack-walk tests to cover ResolveHelperFrame frame enumeration and AMD64 context reconstruction from the TransitionBlock.
Show a summary per file
File Description
src/native/managed/cdac/tests/UnitTests/StackWalkTests.cs Adds mock target/runtime-info setup and new tests covering ResolveHelperFrame enumeration + context update.
src/native/managed/cdac/tests/UnitTests/MockDescriptors/MockDescriptors.Frame.cs Adds mock layouts/builders for ResolveHelperFrame, TransitionBlock, and minimal register sets.
src/native/managed/cdac/tests/TestInfrastructure/TestPlaceholderTarget.cs Makes TryGetThreadContext return false so stack-walk can use its fallback path in tests.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/DataType.cs Introduces DataType.ResolveHelperFrame.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/Frames/ResolveHelperFrame.cs Adds managed cDAC data adapter for ResolveHelperFrame.TransitionBlockPtr.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/StackWalk_1.cs Treats ResolveHelperFrame as resumable (FRAME_ATTR_RESUMABLE) in stack-walk state tracking.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/IPlatformFrameHandler.cs Extends frame-handler interface with HandleTransitionBlock and HandleResolveHelperFrame.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/FrameHelpers.cs Adds ResolveHelperFrame handling for context updates and return-address retrieval.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/BaseFrameHandler.cs Factors common transition-block handling and adds helper for updating argument registers from the transition block.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/ARMFrameHandler.cs Routes transition handling via HandleTransitionBlock and keeps ARM argument-register updates.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/ARM64FrameHandler.cs Updates argument registers for ResolveHelperFrame after applying the transition block.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/AMD64FrameHandler.cs Updates argument registers for ResolveHelperFrame after applying the transition block.
src/coreclr/vm/frames.h Exposes ResolveHelperFrame::m_pTransitionBlock offset via cdac_data<ResolveHelperFrame>.
src/coreclr/vm/datadescriptor/datadescriptor.inc Emits the native cDAC type descriptor for ResolveHelperFrame under FEATURE_RESOLVE_HELPER_DISPATCH.

Copilot's findings

  • Files reviewed: 14/14 changed files
  • Comments generated: 1

Comment on lines 157 to 170
TransitionBlock,
DebuggerEval,
ArgumentRegisters,
CalleeSavedRegisters,
HijackArgs,

Frame,
InlinedCallFrame,
SoftwareExceptionFrame,
FramedMethodFrame,
ResolveHelperFrame,
FuncEvalFrame,
ResumableFrame,
FaultingExceptionFrame,
leculver and others added 3 commits June 11, 2026 07:55
Add ResolveHelperFrame to the cDAC descriptor and managed frame model so stack walking can classify it, recover return addresses, treat it as resumable, and restore transition-block context. Add unit coverage for classification and AMD64 context restoration, including argument registers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@leculver leculver force-pushed the leculver/cdac-resolve-helper-frame branch from adfd317 to 64b2076 Compare June 11, 2026 11:55
Add the directly-read ResolveHelperFrame.TransitionBlockPtr field to the
contract's descriptor table and describe its handling: it uses the
TransitionFrame mechanism but additionally restores argument registers on
all platforms, and is gated by FEATURE_RESOLVE_HELPER_DISPATCH.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 11, 2026 12:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 15/15 changed files
  • Comments generated: 2

ARM64FrameHandler.HandleResolveHelperFrame (restoring argument registers
from the TransitionBlock) was untested. Convert the AMD64-only fact into a
theory covering X64 and Arm64: thread an explicit RuntimeInfoArchitecture
through CreateTarget to select the platform handler, and parameterize the
mock TransitionBlock register names so the Arm64 case restores x0/x19.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

2 participants