Skip to content

Commit

Permalink
Check if the child object is in the heap range before object_gennum
Browse files Browse the repository at this point in the history
  • Loading branch information
cshung committed Jan 19, 2022
1 parent d48a44f commit 5880bc2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43428,8 +43428,15 @@ void GCHeap::SetYieldProcessorScalingFactor (float scalingFactor)

unsigned int GCHeap::WhichGeneration (Object* object)
{
gc_heap* hp = gc_heap::heap_of ((uint8_t*)object);
unsigned int g = hp->object_gennum ((uint8_t*)object);
uint8_t* o = (uint8_t*)object;
#ifdef FEATURE_BASICFREEZE
if (!((o < g_gc_highest_address) && (o >= g_gc_lowest_address)))
{
return max_generation;
}
#endif //FEATURE_BASICFREEZE
gc_heap* hp = gc_heap::heap_of (o);
unsigned int g = hp->object_gennum (o);
dprintf (3, ("%Ix is in gen %d", (size_t)object, g));
return g;
}
Expand Down

0 comments on commit 5880bc2

Please sign in to comment.