Repository navigation
Allow the GcInfoDumper to report scratch registers at safe points (DECODE_NO_VALIDATION) - #129615
Conversation
…CODE_NO_VALIDATION)
A checked/debug build can hit _ASSERTE(flags & ActiveStackFrame) ("Scratch registers cannot be reported for non-leaf frames") in TGcInfoDecoder<...>::ReportRegisterToGC when the GcInfoDumper is used to dump a method whose GC info reports a scratch register live at a safe point. This is reachable today through SOS's gcinfo, e.g. AMD64 GC info reporting rax live at a partially-interruptible safe point. GcInfoDumper::EnumerateStateChanges constructs its decoder with DECODE_NO_VALIDATION and calls EnumerateLiveSlots(®disp, /*reportScratchSlots*/ true, flags | NoReportUntracked, ...) . At safe points it deliberately sets flags = 0 (not ActiveStackFrame ) but still asks for scratch slots, because the dumper's job is to display every encoded slot at every offset - it is not performing a real stackwalk. The assert was written for the real-GC contract (scratch registers are only valid on the active/leaf frame) and does not account for the dumper's explicit DECODE_NO_VALIDATION mode.
|
Tagging subscribers to this area: @anicka-net, @dotnet/gc |
There was a problem hiding this comment.
Pull request overview
This PR adjusts TGcInfoDecoder<...>::ReportRegisterToGC debug-time validation so that scratch registers can be reported even when the decoder is running in DECODE_NO_VALIDATION mode (used by GC info dumping / display scenarios), avoiding _ASSERTE(flags & ActiveStackFrame) failures.
Changes:
- Relax the scratch-register invariant assertion in
ReportRegisterToGCto allowDECODE_NO_VALIDATIONas an alternate “display-only” contract. - Apply the same adjustment across the platform-specific
ReportRegisterToGCimplementations (AMD64, ARM, ARM64, LoongArch64, RISC-V 64).
Copilot Code ReviewHolistic AssessmentMotivation: Justified — the Approach: Correct and minimal. Relaxing the debug assertion by checking Summary: ✅ LGTM. The change is a clean, surgical fix to 5 identical debug-only assertions across all architecture-specific Detailed FindingsDetailed Findings✅ Correctness — Assert relaxation is properly scoped
✅ Consistency — Pattern matches existing codebase conventionThe ✅ Completeness — All architecture variants updatedAll 5 platform-specific ✅ Comments — Accurate and helpfulThe updated comments correctly explain why the relaxation is needed and reference the Note This review was created by GitHub Copilot.
|
A checked/debug build can hit _ASSERTE(flags & ActiveStackFrame) in TGcInfoDecoder<...>::ReportRegisterToGC when the GcInfoDumper is used to dump a method whose GC info reports a scratch register live at a safe point. This is reachable today through SOS's gcinfo, e.g. AMD64 GC info reporting rax live at a partially interruptible safe point. GcInfoDumper::EnumerateStateChanges constructs its decoder with DECODE_NO_VALIDATION and calls EnumerateLiveSlots(®disp, /reportScratchSlots/ true, flags | NoReportUntracked, ...). At safe points it deliberately sets flags = 0 (not ActiveStackFrame ) but still asks for scratch slots, because the dumper's job is to display every encoded slot at every offset - it is not performing a real stackwalk. The assert was written for the real-GC contract (scratch registers are only valid on the active/leaf frame) and does not account for the dumper's explicit DECODE_NO_VALIDATION mode.