@@ -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