Skip to content

Commit da8ffe6

Browse files
authored
[release/10.0] Fix heap_segment_used watermark after compaction (#128342)
Backport of #128217 to release/10.0 ## Customer Impact - [x] Customer reported - [ ] Found internally GC with large pages enabled in regions mode can lead to intermittent crashes due to non-zeroed memory being returned for an allocation request that expects the memory to be zeroed. ## Regression - [x] Yes, introduced when GC regions were enabled - [ ] No ## Testing CI tests, local testing using targeted repro app from the customer, GC tests ## Risk Low. It adds maintaining `heap_segment_used` watermark after compaction so that it covers all the touched memory in a region. Before this change, it was stale (lower) for regions that receive relocated objects.
1 parent d8f92c8 commit da8ffe6

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/coreclr/gc/gc.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12636,6 +12636,11 @@ size_t gc_heap::decommit_heap_segment_pages_worker (heap_segment* seg,
1263612636
void gc_heap::decommit_heap_segment (heap_segment* seg)
1263712637
{
1263812638
#ifdef USE_REGIONS
12639+
if (use_large_pages_p)
12640+
{
12641+
return;
12642+
}
12643+
1263912644
if (!dt_high_memory_load_p())
1264012645
{
1264112646
return;
@@ -38102,6 +38107,21 @@ void gc_heap::compact_phase (int condemned_gen_number,
3810238107

3810338108
recover_saved_pinned_info();
3810438109

38110+
#ifdef USE_REGIONS
38111+
for (int i = 0; i <= min (condemned_gen_number + 1, (int)max_generation); i++)
38112+
{
38113+
generation* gen = generation_of (i);
38114+
for (heap_segment* region = generation_start_segment_rw (gen);
38115+
region != nullptr;
38116+
region = heap_segment_next_rw (region))
38117+
{
38118+
uint8_t* plan_allocated = heap_segment_plan_allocated (region);
38119+
if (plan_allocated > heap_segment_used (region))
38120+
heap_segment_used (region) = plan_allocated;
38121+
}
38122+
}
38123+
#endif //USE_REGIONS
38124+
3810538125
concurrent_print_time_delta ("compact end");
3810638126

3810738127
dprintf (2, (ThreadStressLog::gcEndCompactMsg(), heap_number));

0 commit comments

Comments
 (0)