Fix variable shadowing bug in DacFreeRegionEnumerator::AddServerRegions#125068
Fix variable shadowing bug in DacFreeRegionEnumerator::AddServerRegions#125068max-charlamb merged 2 commits intomainfrom
Conversation
The inner for loop reused variable name 'i', shadowing the outer heap index loop variable. This caused AddSegmentList calls to receive count_free_region_kinds instead of the heap index for freeable_soh/uoh segments, and the region kind index instead of the heap index for free regions. Rename the inner loop variable to 'kind' and ensure all AddSegmentList calls pass 'i' (the heap index) as the last argument. Co-authored-by: max-charlamb <44248479+max-charlamb@users.noreply.github.com>
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
There was a problem hiding this comment.
Pull request overview
This PR fixes a variable shadowing bug in DacFreeRegionEnumerator::AddServerRegions in the DAC (Data Access Component) layer used for GC heap inspection. The inner loop variable i shadowed the outer heap-index loop variable i, causing AddSegmentList calls for freeable_soh_segment and freeable_uoh_segment to pass count_free_region_kinds as the heap index instead of the actual heap index. This would corrupt the mem.Heap field in reported SOSMemoryRegion entries, misattributing SOH/UOH freeable segments to the wrong GC heap.
Changes:
- Renamed the inner loop variable in
AddServerRegionsfromitokind, eliminating the shadowing and ensuring all threeAddSegmentListcalls correctly pass the outer heap indexi.
|
@copilot, can you analyze the CI failures? |
These seem completely unrelated to DAC things, perhaps copilot will just be able to fix them :) |
CI has 2 failed jobs out of 80 total (78 passed) on build 1316693. None are related to this PR's change (
These failures are in completely unrelated areas (JSON serialization, HTTP networking, WebSockets) and have open "Known Build Error" tracking issues. The Build Analysis check is red because not all failures are automatically matched, but manual inspection confirms they're pre-existing. Safe to retry with Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
/ba-g test failures unrelated to change |
Description
Variable shadowing bug in
DacFreeRegionEnumerator::AddServerRegions— the inner loop overcount_free_region_kindsreusedias its loop variable, shadowing the outer heap indexi. After the inner loop, theAddSegmentListcalls forfreeable_soh_segmentandfreeable_uoh_segmentpassedcount_free_region_kindsinstead of the heap index.Before:
After:
Renamed the inner loop variable to
kind. All threeAddSegmentListcalls now correctly pass the heap indexi.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.