From 0fc9fddc181e882ec40758b84e97f094dca3b57c Mon Sep 17 00:00:00 2001 From: mrsharm Date: Thu, 1 Aug 2024 16:30:16 -0700 Subject: [PATCH 1/3] Added a fix for an assertion failure with an incorrect assumption about the equality of heap segment used and mem --- src/coreclr/gc/gc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index 05e4ffb9cd0b8..91efbc5d75437 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -44144,7 +44144,7 @@ size_t gc_heap::decommit_region (heap_segment* region, int bucket, int h_number) } #endif //BACKGROUND_GC - if (use_large_pages_p) + if (require_clearing_memory_p) { assert (heap_segment_used (region) == heap_segment_mem (region)); } From 06805e1d22ef45da749235083b11a8691ec43d60 Mon Sep 17 00:00:00 2001 From: Mukund Raghav Sharma Date: Tue, 6 Aug 2024 17:11:21 -0700 Subject: [PATCH 2/3] Conditionally call delete region if and only if require_clearing_memory_p is true --- src/coreclr/gc/gc.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index 91efbc5d75437..0a5c0df32d283 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -44156,7 +44156,10 @@ size_t gc_heap::decommit_region (heap_segment* region, int bucket, int h_number) assert ((region->flags & heap_segment_flags_ma_committed) == 0); #endif //BACKGROUND_GC - global_region_allocator.delete_region (get_region_start (region)); + if (require_clearing_memory_p) + { + global_region_allocator.delete_region (get_region_start (region)); + } return decommit_size; } From 1f7cf553519e1d63972cd19e485cb9e571606ada Mon Sep 17 00:00:00 2001 From: Mukund Raghav Sharma Date: Tue, 6 Aug 2024 17:50:54 -0700 Subject: [PATCH 3/3] Set decommit_size = 0 if require_clearing_memory_p == false --- src/coreclr/gc/gc.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index 0a5c0df32d283..e194b66631a10 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -44161,6 +44161,12 @@ size_t gc_heap::decommit_region (heap_segment* region, int bucket, int h_number) global_region_allocator.delete_region (get_region_start (region)); } + else + { + // If decommit failed or if we are using large pages, set this value to 0. + decommit_size = 0; + } + return decommit_size; } #endif //USE_REGIONS