From 346197120d99029cf3d3200312ecb00858c7c627 Mon Sep 17 00:00:00 2001 From: Lao Nong <303248153@qq.com> Date: Thu, 26 Sep 2019 21:36:06 -0400 Subject: [PATCH] Fix out of range access in GetRecycleMemoryInfo (#26873) --- src/vm/win32threadpool.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/vm/win32threadpool.h b/src/vm/win32threadpool.h index 058eaf460150..d7479a9c1cb4 100644 --- a/src/vm/win32threadpool.h +++ b/src/vm/win32threadpool.h @@ -749,7 +749,9 @@ class ThreadpoolMgr #else // !FEATURE_PAL if (PAL_HasGetCurrentProcessorNumber()) { - processorNumber = GetCurrentProcessorNumber(); + // On linux, GetCurrentProcessorNumber which uses sched_getcpu() can return a value greater than the number + // of processors reported by sysconf(_SC_NPROCESSORS_ONLN) when using OpenVZ kernel. + processorNumber = GetCurrentProcessorNumber()%NumberOfProcessors; } #endif // !FEATURE_PAL return pRecycledListPerProcessor[processorNumber][memType];