Repository navigation
[cDAC] Fix LoongArch64 epilog scope sizing - #132226
Merged
Merged
Conversation
Co-authored-by: Copilot <[email protected]> Copilot-Session: 11b73ad8-c726-42c3-bc38-a8360c68b4de
Contributor
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
Contributor
There was a problem hiding this comment.
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
Contributor
There was a problem hiding this comment.
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
headerWordwith 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
enabled auto-merge (squash)
August 12, 2026 20:07
max-charlamb
approved these changes
Aug 12, 2026
Open
3 tasks
Contributor
Author
|
/ba-g timeout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See
runtime/src/coreclr/unwinder/loongarch64/unwinder.cpp
Line 418 in abb0f8d