Skip to content

Fix x86 Debugger_STRData layout and ESP adjustment in cDAC DBI - #130275

Merged
tommcdon merged 3 commits into
dotnet:mainfrom
tommcdon:dev/tommcdon/cdac-dbi-x86-stackwalk
Jul 10, 2026
Merged

tommcdon merged 3 commits into
dotnet:mainfrom
tommcdon:dev/tommcdon/cdac-dbi-x86-stackwalk

Conversation

@tommcdon

@tommcdon tommcdon commented Jul 7, 2026 •

Copy link
Copy Markdown
Member

Standardizes DBI stack-frame/continuation structures on fixed-width CORDB_ADDRESS making the 32-bit DBI compatible with the CDAC

  • Debugger_STRData.fp/ctx, fpParentOrSelf, and GetFramePointer → CORDB_ADDRESS/ulong
  • ParseContinuation pDiagnosticIP → CORDB_ADDRESS*
  • Removed now dead X86ESPIgnoresCalleePoppedArgs mechanism
  • Zero ctx for cStubFrame entries

@tommcdon tommcdon added this to the 11.0.0 milestone Jul 7, 2026
@tommcdon
tommcdon requested review from max-charlamb and rcj1 July 7, 2026 01:39
@tommcdon tommcdon self-assigned this Jul 7, 2026
Copilot AI review requested due to automatic review settings July 7, 2026 01:39
@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 fixes cDAC DBI interop correctness by updating stack-walk-related structures and signatures to respect host pointer size and native anonymous-union layout, and by tightening x86 stack-walk state tracking to avoid reusing stale stack parameter sizes.

Changes:

  • Updated Debugger_STRData / Debugger_JITFuncData to use nuint for host-pointer-sized fields and modeled the native anonymous union via a nested explicit-layout union.
  • Updated DacDbiImpl to use the new union member (u.stubFrame) and adjusted ParseContinuation to use a pointer-sized diagnostic IP (nuint*).
  • Reset LastFramelessStackParameterSize when transitioning through native-frame states to avoid incorrect x86 ESP adjustments across consecutive native markers.

Reviewed changes

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

File Description
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs Corrects interop struct layouts and pointer-sized fields; updates ParseContinuation signature to match native PCODE*.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs Adapts implementation to new Debugger_STRData union shape and pointer-sized diagnostic IP handling.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/StackWalk_1.cs Prevents stale x86 stack-parameter-size reuse across native-marker transitions during stack walks.

@tommcdon
tommcdon marked this pull request as ready for review July 7, 2026 20:36
Copilot AI review requested due to automatic review settings July 7, 2026 20:36

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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Comment thread src/coreclr/debug/inc/dacdbiinterface.h Resolved
Copilot AI review requested due to automatic review settings July 8, 2026 03:10

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

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Comment thread src/coreclr/debug/inc/dacdbiinterface.h Resolved
Copilot AI review requested due to automatic review settings July 8, 2026 03:52

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

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Comment thread src/coreclr/debug/inc/dacdbiinterface.h Resolved
…n overrun, and GetStackWalkCurrentContext ESP

On x86 the cDAC DBI path had three defects that broke ICorDebug attach and
async stackwalks when DOTNET_ENABLE_CDAC=1:

- Debugger_STRData.fp was a host-sized FramePointer (4 bytes on x86) while the
  managed cDAC treats it as a fixed-width value. Normalize fp to CORDB_ADDRESS
  so the native mscordbi consumer and the managed cDAC agree on struct layout;
  the RS converts to/from FramePointer at the boundary. ctx stays a host-sized
  pointer. Fixes the internal-frames (GetActiveInternalFrames) attach hang.

- ParseContinuation declared pDiagnosticIP as PCODE* (4 bytes on x86) while the
  managed cDAC writes 8 bytes, overrunning the caller's stack. Change the native
  signature to CORDB_ADDRESS* to match.

- GetStackWalkCurrentContext applied an x86 callee-popped-args adjustment that
  the native implementation does not: native builds the returned context from
  REGDISPLAY->pCurrentContext, and the M2U adjustment writes only REGDISPLAY->SP,
  not pCurrentContext->Esp. Return the raw context and remove the now-dead
  X86ESPIgnoresCalleePoppedArgs mechanism.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings July 9, 2026 14:51
@tommcdon
tommcdon force-pushed the dev/tommcdon/cdac-dbi-x86-stackwalk branch from 879eb71 to 7b2d291 Compare July 9, 2026 14:51

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

…inuation outputs

- Remove the StackwalkFlag.X86ESPIgnoresCalleePoppedArgs description from the
  StackWalk data contract doc to match its removal from the implementation.
- Initialize ParseContinuation out parameters (pDiagnosticIP, pNextContinuation,
  pState) on the numFound < 3 / E_FAIL failure path so callers never observe
  uninitialized values.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings July 9, 2026 15:43
Remove the lone inline // FramePointer (CORDB_ADDRESS) comment on
Debugger_JITFuncData.fpParentOrSelf; it was the only annotated field among
otherwise-bare members and stood out.

Co-authored-by: Copilot <[email protected]>

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

Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 9, 2026 15:49

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

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

@tommcdon

Copy link
Copy Markdown
Member Author

/ba-g failures are unrelated

@tommcdon
tommcdon enabled auto-merge (squash) July 10, 2026 18:17
@tommcdon
tommcdon merged commit a63bcc6 into dotnet:main Jul 10, 2026
138 of 141 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot modified the milestones: 11.0.0, 11.0-preview7 Jul 11, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
Standardizes DBI stack-frame/continuation structures on fixed-width
`CORDB_ADDRESS` making the 32-bit DBI compatible with the CDAC

- `Debugger_STRData.fp`/`ctx`, `fpParentOrSelf`, and `GetFramePointer` →
`CORDB_ADDRESS`/`ulong`
- `ParseContinuation` `pDiagnosticIP` → `CORDB_ADDRESS*`
- Removed now dead `X86ESPIgnoresCalleePoppedArgs` mechanism
- Zero `ctx` for `cStubFrame` entries

---------

Co-authored-by: Copilot <[email protected]>
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants