diff --git a/src/coreclr/src/gc/gc.cpp b/src/coreclr/src/gc/gc.cpp index 38b6d8e97d56b1..6eb6142f27b7b4 100644 --- a/src/coreclr/src/gc/gc.cpp +++ b/src/coreclr/src/gc/gc.cpp @@ -34133,10 +34133,19 @@ CObjectHeader* gc_heap::allocate_uoh_object (size_t jsize, uint32_t flags, int g //mark the new block specially so we know it is a new object if ((result < current_highest_address) && (result >= current_lowest_address)) { - dprintf (3, ("Setting mark bit at address %Ix", - (size_t)(&mark_array [mark_word_of (result)]))); +#ifdef DOUBLY_LINKED_FL + heap_segment* seg = seg_mapping_table_segment_of (result); + // if bgc_allocated is 0 it means it was allocated during bgc sweep, + // and since sweep does not look at this seg we cannot set the mark array bit. + uint8_t* background_allocated = heap_segment_background_allocated(seg); + if (background_allocated != 0) +#endif //DOUBLY_LINKED_FL + { + dprintf(3, ("Setting mark bit at address %Ix", + (size_t)(&mark_array[mark_word_of(result)]))); - mark_array_set_marked (result); + mark_array_set_marked(result); + } } } } @@ -34515,7 +34524,7 @@ BOOL gc_heap::fgc_should_consider_object (uint8_t* o, no_bgc_mark_p = TRUE; } - dprintf (3, ("bgc mark %Ix: %s (bm: %s)", o, (no_bgc_mark_p ? "no" : "yes"), (background_object_marked (o, FALSE) ? "yes" : "no"))); + dprintf (3, ("bgc mark %Ix: %s (bm: %s)", o, (no_bgc_mark_p ? "no" : "yes"), ((no_bgc_mark_p || background_object_marked (o, FALSE)) ? "yes" : "no"))); return (no_bgc_mark_p ? TRUE : background_object_marked (o, FALSE)); } diff --git a/src/coreclr/src/gc/gcpriv.h b/src/coreclr/src/gc/gcpriv.h index 23f5bc83633955..223db42108ed4d 100644 --- a/src/coreclr/src/gc/gcpriv.h +++ b/src/coreclr/src/gc/gcpriv.h @@ -65,8 +65,7 @@ inline void FATAL_GC_ERROR() // We need the lower 3 bits in the MT to do our bookkeeping so doubly linked free list is only for 64-bit #ifdef HOST_64BIT -// To be enabled. -// #define DOUBLY_LINKED_FL +#define DOUBLY_LINKED_FL #endif //HOST_64BIT #ifndef FEATURE_REDHAWK