Skip to content

[cDAC] Fix LoongArch64 epilog scope sizing - #132226

Merged
rcj1 merged 2 commits into
dotnet:mainfrom
rcj1:loong-audit-fix
Aug 12, 2026
Merged

rcj1 merged 2 commits into
dotnet:mainfrom
rcj1:loong-audit-fix

Conversation

@rcj1

@rcj1 rcj1 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 11b73ad8-c726-42c3-bc38-a8360c68b4de
@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

Fixes LoongArch64 unwind behavior in cDAC stack walking by correctly sizing epilog scopes so the unwind logic can detect when execution is at the epilog return instruction and avoid re-applying already-completed stack adjustments.

Changes:

  • Adjust epilog scope sizing in LoongArch64Unwinder.ComputeScopeSize(...) by accounting for the extra epilog return instruction.
  • Add a unit test covering the “PC at epilog return” case to ensure stack pointer adjustment is not repeated.
Show a summary per file
File Description
src/native/managed/cdac/tests/UnitTests/StackWalkTests.cs Adds a regression unit test validating LoongArch64 epilog-return unwinding does not duplicate stack adjustment.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/LoongArch64/LoongArch64Unwinder.cs Fixes epilog scope size computation by including the final epilog instruction, preventing incorrect unwind code execution at return.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings August 12, 2026 18:33

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.

Review details

Suppressed comments (2)

src/native/managed/cdac/tests/UnitTests/StackWalkTests.cs:45

  • The unwind header word is currently constructed as a single bitwise expression with no indication of which fields/bits are being set. In this file, similar bitfield encodings (e.g., the ARM compact unwind data below) annotate each component, which makes the test much easier to understand and maintain. Consider splitting this into a named headerWord with per-field comments.
        byte[] unwindData = new byte[2 * sizeof(uint)];
        helpers.Write(unwindData.AsSpan(0, sizeof(uint)), 16u | (1u << 21) | (1u << 27));

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/LoongArch64/LoongArch64Unwinder.cs:329

  • The epilog-only scopeSize++ adjustment is a subtle rule; adding a brief comment (like the ARM/ARM64 unwinders do) would make it clear why epilogs need an extra instruction accounted for.
        if (isEpilog)
            scopeSize++;

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@rcj1
rcj1 enabled auto-merge (squash) August 12, 2026 20:07
@rcj1

rcj1 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

/ba-g timeout

@rcj1
rcj1 merged commit 1b245d5 into dotnet:main Aug 12, 2026
69 of 71 checks passed
@rcj1
rcj1 deleted the loong-audit-fix branch August 12, 2026 23:59
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc1 milestone Aug 13, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 13, 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.

3 participants