From 6babcadbba1b3dca1de837a3003c8a005e30ab9a Mon Sep 17 00:00:00 2001 From: Andrew Au Date: Wed, 14 Aug 2024 08:26:04 -0700 Subject: [PATCH] Reduce committed bytes if mark array commit fails --- src/coreclr/gc/gc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index 4f15f554ffb41..4f1943ed4c537 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -9579,6 +9579,7 @@ int gc_heap::grow_brick_card_tables (uint8_t* start, #endif //CARD_BUNDLE size_t alloc_size = card_table_element_layout[total_bookkeeping_elements]; + size_t commit_size = 0; uint8_t* mem = (uint8_t*)GCToOSInterface::VirtualReserve (alloc_size, 0, virtual_reserve_flags); if (!mem) @@ -9592,14 +9593,16 @@ int gc_heap::grow_brick_card_tables (uint8_t* start, { // in case of background gc, the mark array will be committed separately (per segment). - size_t commit_size = card_table_element_layout[seg_mapping_table_element + 1]; + commit_size = card_table_element_layout[seg_mapping_table_element + 1]; if (!virtual_commit (mem, commit_size, recorded_committed_bookkeeping_bucket)) { + commit_size = 0; dprintf (GC_TABLE_LOG, ("Table commit failed")); set_fgm_result (fgm_commit_table, commit_size, uoh_p); goto fail; } + } ct = (uint32_t*)(mem + card_table_element_layout[card_table_element]); @@ -9771,6 +9774,7 @@ int gc_heap::grow_brick_card_tables (uint8_t* start, dprintf (GC_TABLE_LOG, ("GCToOSInterface::VirtualRelease failed")); assert (!"release failed"); } + reduce_committed_bytes (mem, commit_size, recorded_committed_bookkeeping_bucket, -1, true); } return -1; @@ -47495,10 +47499,6 @@ void gc_heap::verify_committed_bytes_per_heap() void gc_heap::verify_committed_bytes() { -#ifndef USE_REGIONS - // TODO, https://github.com/dotnet/runtime/issues/102706, re-enable the testing after fixing this bug - return; -#endif //!USE_REGIONS size_t total_committed = 0; size_t committed_decommit; // unused size_t committed_free; // unused