From 6cc557e826b9b256aa6145c17a5f5df1d71a7d9c Mon Sep 17 00:00:00 2001 From: Maoni0 Date: Wed, 21 Aug 2024 02:12:40 -0700 Subject: [PATCH] fixing an assert --- src/coreclr/gc/gc.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index d4d1f44d2d5f5b..a17e50bf7b2ec8 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -6999,8 +6999,21 @@ void gc_heap::gc_thread_function () while (1) { - // inactive GC threads may observe gc_t_join.joined() being true here - assert ((n_heaps <= heap_number) || !gc_t_join.joined()); +#ifdef DYNAMIC_HEAP_COUNT + if (gc_heap::dynamic_adaptation_mode == dynamic_adaptation_to_application_sizes) + { + // Inactive GC threads may observe gc_t_join.joined() being true here. + // Before the 1st GC happens, h0's GC thread can also observe gc_t_join.joined() being true because it's + // also inactive as the main thread (that inits the GC) will act as h0 (to call change_heap_count). + assert (((heap_number == 0) && (VolatileLoadWithoutBarrier (&settings.gc_index) == 0)) || + (n_heaps <= heap_number) || + !gc_t_join.joined()); + } + else +#endif //DYNAMIC_HEAP_COUNT + { + assert (!gc_t_join.joined()); + } if (heap_number == 0) {