Skip to content

Commit 2e698fb

Browse files
EgorBoMaoni0
andauthored
Don't scan bricks of frozen segments in verify_heap (#76645)
Co-authored-by: Maoni0 <maoni@microsoft.com>
1 parent fec0221 commit 2e698fb

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

src/coreclr/gc/gc.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44422,13 +44422,35 @@ void gc_heap::verify_heap (BOOL begin_gc_p)
4442244422
uint8_t* curr_object = heap_segment_mem (seg);
4442344423
uint8_t* prev_object = 0;
4442444424

44425+
bool verify_bricks_p = true;
4442544426
#ifdef USE_REGIONS
44427+
if (heap_segment_read_only_p(seg))
44428+
{
44429+
dprintf(1, ("seg %Ix is ro! Shouldn't happen with regions", (size_t)seg));
44430+
FATAL_GC_ERROR();
44431+
}
4442644432
if (heap_segment_gen_num (seg) != heap_segment_plan_gen_num (seg))
4442744433
{
4442844434
dprintf (1, ("Seg %Ix, gen num is %d, plan gen num is %d",
4442944435
heap_segment_mem (seg), heap_segment_gen_num (seg), heap_segment_plan_gen_num (seg)));
4443044436
FATAL_GC_ERROR();
4443144437
}
44438+
#else //USE_REGIONS
44439+
if (heap_segment_read_only_p(seg))
44440+
{
44441+
size_t current_brick = brick_of(max(heap_segment_mem(seg), lowest_address));
44442+
size_t end_brick = brick_of(min(heap_segment_reserved(seg), highest_address) - 1);
44443+
while (current_brick <= end_brick)
44444+
{
44445+
if (brick_table[current_brick] != 0)
44446+
{
44447+
dprintf(1, ("Verifying Heap: %Ix brick of a frozen segment is not zeroed", current_brick));
44448+
FATAL_GC_ERROR();
44449+
}
44450+
current_brick++;
44451+
}
44452+
verify_bricks_p = false;
44453+
}
4443244454
#endif //USE_REGIONS
4443344455

4443444456
#ifdef BACKGROUND_GC
@@ -44470,11 +44492,11 @@ void gc_heap::verify_heap (BOOL begin_gc_p)
4447044492
#endif //!USE_REGIONS
4447144493

4447244494
#ifdef USE_REGIONS
44473-
if (curr_gen_num != 0)
44495+
if (verify_bricks_p && curr_gen_num != 0)
4447444496
#else
4447544497
// If object is not in the youngest generation, then lets
4447644498
// verify that the brick table is correct....
44477-
if (((seg != ephemeral_heap_segment) ||
44499+
if (verify_bricks_p && ((seg != ephemeral_heap_segment) ||
4447844500
(brick_of(curr_object) < brick_of(begin_youngest))))
4447944501
#endif //USE_REGIONS
4448044502
{

0 commit comments

Comments
 (0)