From 334d57e27270a744a7cf8df7d1fadc9dc14751de Mon Sep 17 00:00:00 2001 From: Andrew Au Date: Wed, 7 Aug 2024 06:51:39 -0700 Subject: [PATCH] Make sure get_total_soh_stable_size never return zero (#106043) --- 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 1d148ad33030d..4f15f554ffb41 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -22912,6 +22912,12 @@ size_t gc_heap::get_total_soh_stable_size() total_stable_size += hp->generation_size (max_generation - 1) / 2; } + if (!total_stable_size) + { + // Setting a temp value before a GC naturally happens (ie, due to allocation). + total_stable_size = dd_min_size (g_heaps[0]->dynamic_data_of (max_generation - 1)); + } + return total_stable_size; } }