Skip to content

Commit d31f394

Browse files
[release/9.0-staging] handle case of Proc Index > MAX_SUPPORTED_CPUS (#109385)
* handle case of Proc Index > MAX_SUPPORTED_CPUS * PR feedback * Update comment --------- Co-authored-by: Manish Godse <[email protected]>
1 parent 409f6a4 commit d31f394

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/coreclr/gc/gc.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6404,7 +6404,11 @@ class heap_select
64046404
if (GCToOSInterface::CanGetCurrentProcessorNumber())
64056405
{
64066406
uint32_t proc_no = GCToOSInterface::GetCurrentProcessorNumber();
6407-
proc_no_to_heap_no[proc_no] = (uint16_t)heap_number;
6407+
// For a 32-bit process running on a machine with > 64 procs,
6408+
// even though the process can only use up to 32 procs, the processor
6409+
// index can be >= 64; or in the cpu group case, if the process is not running in cpu group #0,
6410+
// the GetCurrentProcessorNumber will return a number that's >= 64.
6411+
proc_no_to_heap_no[proc_no % MAX_SUPPORTED_CPUS] = (uint16_t)heap_number;
64086412
}
64096413
}
64106414

@@ -6426,7 +6430,11 @@ class heap_select
64266430
if (GCToOSInterface::CanGetCurrentProcessorNumber())
64276431
{
64286432
uint32_t proc_no = GCToOSInterface::GetCurrentProcessorNumber();
6429-
int adjusted_heap = proc_no_to_heap_no[proc_no];
6433+
// For a 32-bit process running on a machine with > 64 procs,
6434+
// even though the process can only use up to 32 procs, the processor
6435+
// index can be >= 64; or in the cpu group case, if the process is not running in cpu group #0,
6436+
// the GetCurrentProcessorNumber will return a number that's >= 64.
6437+
int adjusted_heap = proc_no_to_heap_no[proc_no % MAX_SUPPORTED_CPUS];
64306438
// with dynamic heap count, need to make sure the value is in range.
64316439
if (adjusted_heap >= gc_heap::n_heaps)
64326440
{

0 commit comments

Comments
 (0)