Repository navigation
[cDAC] Fix riscv64/loongarch64 gaps and interpreter stack walking - #137365
Conversation
Co-authored-by: Cursor <[email protected]>
|
Azure Pipelines: Successfully started running 5 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
Co-authored-by: Cursor <[email protected]>
|
osx-x64 leg dead-lettered. |
|
@jkotas, @steveisok, I've tested this and microsoft/clrmd#1527 on linux-riscv64 device and all tests in both repos are now passing. Could you please take a look. Thanks! cc @shushanhf (LA64 tests of both PRs were ran under QEMU) |
There was a problem hiding this comment.
🟡 Changes recommended
GC scanning skips a non-null continuation when starting from an interpreted context, risking a missed root, while the new classification and slot-resolution paths lack focused regression coverage.
3 open issues
What changed in this PR
This PR improves cDAC’s diagnostic support for RISC-V and LoongArch64 and aligns interpreter stack walking and GC-root reporting with native runtime behavior.
Changes:
- Corrects RISC-V context offsets and fills architecture-specific register, unwinding, and floating-point struct classification gaps.
- Adds interpreter-aware GC decoding, continuation-root reporting, funclet detection, and caller-context handling.
- Updates contract documentation and adds context-layout regression tests.
Validation was limited to source inspection; no builds or tests were run.
| File | Description |
|---|---|
| PlatformContextTests.cs | Tests RISC-V context field offsets. |
| ClrDataFrame.cs | Adds architecture-specific stack-pointer register numbers. |
| InterpreterFrame.cs | Exposes the continuation field address. |
| StackWalk_1.ExceptionHandling.cs | Uses interpreter-aware caller contexts during exception handling. |
| StackWalk_1.cs | Integrates interpreter decoding and caller-context unwinding. |
| GcScanner.cs | Adds interpreter slot filtering and continuation scanning. |
| RISCV64FrameHandler.cs | Records the interpreter owner in A0. |
| LoongArch64FrameHandler.cs | Records the interpreter owner in A0. |
| FrameHelpers.cs | Computes complete interpreted caller contexts. |
| RISCV64Context.cs | Adds R0 and corrects register offsets. |
| RISCV64Unwinder.cs | Handles missing unwind information. |
| LoongArch64Unwinder.cs | Handles missing unwind information. |
| RuntimeTypeSystem_1.cs | Implements floating-point struct classification. |
| ExecutionManagerCore.cs | Identifies interpreted funclets through exception-clause ranges. |
| CdacTypeHandle.cs | Maps classification results to calling-convention data. |
| IRuntimeTypeSystem.cs | Defines the classification contract and result types. |
| frames.h | Exposes the native continuation field offset. |
| datadescriptor.inc | Publishes the continuation data descriptor. |
| StackWalk.md | Documents interpreter unwinding and root scanning. |
| RuntimeTypeSystem.md | Specifies floating-point struct classification. |
| data-descriptor-meanings.json | Describes the continuation descriptor. |
Review effort: Balanced
FpStructClassificationTests covers TryGetFpStructInRegistersClassification on RISC-V and LoongArch64: one and two floating-point fields, mixed integer and reference fields in both orders, ordering by offset, nested structs, fixed buffers and inline arrays, and the fallbacks to the integer calling convention (no floating-point field, too many fields, larger than 16 bytes, overlapping fields, too many array elements, other architectures). The StackWalk tests cover GC reporting of an interpreted frame: decoding with the interpreter GC info encoding, frame-relative slot addresses, and excluding slots at and above the stack of an active callee while keeping them when the callee's ip is null. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
|
- Make InterpreterFrame.Continuation optional: runtimes that support StackWalk version 1 but predate the descriptor entry no longer fail the GC scan; the continuation root is skipped for them. - Route StackWalkData's cached caller context through the interpreter-aware GetCallerContext helper so CheckForSkippedFrames unwinds interpreted frames the same way as the other caller-context paths. - Document FpStructMaxSize and FpStructMaxNestingDepth in RuntimeTypeSystem.md and use them in the pseudocode. - Note in StackWalk.md that Continuation is optional and what happens when it is absent. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The nesting guard is a cDAC implementation detail, not a contract constant. Co-Authored-By: Claude Opus 5.5 <[email protected]>


Brings the riscv64/loongarch64 cDAC on par with arm64 and fixes interpreter stack walking found while running the cDAC stress tests (
DOTNET_CdacStress=0x101/0x201) on riscv64 hardware.riscv64/loongarch64:
RISCV64Contextwas missingR0, so every GPR andPcwas read 8 bytes off the nativeCONTEXT(all GCREFS stress runs failed).TryGetFpStructInRegistersClassificationin RuntimeTypeSystem, mirroringMethodTable::GetFpStructInRegistersInfo) instead of throwingNotImplementedExceptionfrom the calling convention.InterpreterFrameinInlinedCallFramehandling, null unwind info check in the unwinders, and SP register numbers inClrDataFrame.Interpreter (all architectures):
InterpreterFrame's continuation (newContinuationdata descriptor field).VirtualUnwindInterpreterCallFrame, so funclet parents and unwound frames are skipped as in the runtime.With these, all cDAC stress debuggees pass on riscv64 in both JIT and
DOTNET_Interpreter=*modes, and the cDAC dump tests pass on riscv64 dumps.Depends on microsoft/clrmd#1527 (for dump tests on riscv64/loongarch64) and #137337 (for interpreter on riscv64/loongarch64).