Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6450,7 +6450,11 @@ class heap_select
if (GCToOSInterface::CanGetCurrentProcessorNumber())
{
uint32_t proc_no = GCToOSInterface::GetCurrentProcessorNumber();
proc_no_to_heap_no[proc_no] = (uint16_t)heap_number;
// For a 32-bit process running on a machine with > 64 procs,
// even though the process can only use up to 32 procs, the processor
// index can be >= 64; or in the cpu group case, if the process is not running in cpu group #0,
// the GetCurrentProcessorNumber will return a number that's >= 64.
proc_no_to_heap_no[proc_no % MAX_SUPPORTED_CPUS] = (uint16_t)heap_number;
}
}

Expand All @@ -6472,7 +6476,11 @@ class heap_select
if (GCToOSInterface::CanGetCurrentProcessorNumber())
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this was code from before but do we need adjusted_heap to be signed? Will there ever be a case where adjusted_heap is negative?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't believe that could occur.

uint32_t proc_no = GCToOSInterface::GetCurrentProcessorNumber();
int adjusted_heap = proc_no_to_heap_no[proc_no];
// For a 32-bit process running on a machine with > 64 procs,
// even though the process can only use up to 32 procs, the processor
// index can be >= 64; or in the cpu group case, if the process is not running in cpu group #0,
// the GetCurrentProcessorNumber will return a number that's >= 64.
int adjusted_heap = proc_no_to_heap_no[proc_no % MAX_SUPPORTED_CPUS];
// with dynamic heap count, need to make sure the value is in range.
if (adjusted_heap >= gc_heap::n_heaps)
{
Expand Down