Fix inverted IsNull check in RangeSectionMap::EnumMemoryRangeSectionMapLevel#124862
Fix inverted IsNull check in RangeSectionMap::EnumMemoryRangeSectionMapLevel#124862max-charlamb wants to merge 1 commit intomainfrom
Conversation
…apLevel The template overload of EnumMemoryRangeSectionMapLevel (handling levels L2-L5 on 64-bit) had an inverted condition: it called IsNull() without negation, causing it to skip all populated entries and attempt to dereference null pointers. The non-template L1 overload at line 1538 correctly uses !IsNull(). This bug meant EnumMemoryRegions for the RangeSectionMap never actually enumerated anything below the top level on 64-bit, potentially causing incomplete dumps where RangeSection data is missing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes a logic bug in CoreCLR’s DAC memory enumeration for RangeSectionMap by making the template recursion (used for deeper map levels on 64-bit) skip null entries and only recurse into populated ones, matching the L1 non-template overload.
Changes:
- Invert the
IsNull()condition inRangeSectionMap::EnumMemoryRangeSectionMapLevel(template overload) to avoid recursing into null slots and skipping valid ones.
|
Is this enough to make your test pass or is there more? |
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
I don't know for sure. The failing SOS test does not produce a dump. I am working on adding a dump, but it requires a non-deterministic run on CI. With copilot, I found several bugs in the unwinder which could have impacted the stackwalk: |
Summary
One-line fix: invert the IsNull() condition in the template overload of EnumMemoryRangeSectionMapLevel to match the non-template L1 overload.
Problem
The template overload of
EnumMemoryRangeSectionMapLevel(handling levels L2–L5 on 64-bit) has an inverted condition at line 1553 ofcodeman.h:The non-template L1 overload at line 1538 correctly uses !IsNull():
This bug means
EnumMemoryRegionsfor theRangeSectionMapnever enumerates anything below the top level on 64-bit (where levels L2–L5 use the template), and attempts to dereference null pointers for empty slots. This could cause incomplete DAC memory enumeration during dump generation.