From 772accd3c613bf61eba09100facd7e51f1f31276 Mon Sep 17 00:00:00 2001 From: 303248153 <303248153@qq.com> Date: Wed, 13 Nov 2019 05:57:10 +0900 Subject: [PATCH] Fix out of range access in GetRecycleMemoryInfo (dotnet/coreclr#26873) (dotnet/coreclr#26912) Commit migrated from https://github.com/dotnet/coreclr/commit/2c2bbb50280edcc03fbf946d89ebc01dfff62d76 --- src/coreclr/src/vm/win32threadpool.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/coreclr/src/vm/win32threadpool.h b/src/coreclr/src/vm/win32threadpool.h index 1288588..d112735 100644 --- a/src/coreclr/src/vm/win32threadpool.h +++ b/src/coreclr/src/vm/win32threadpool.h @@ -749,7 +749,9 @@ public: #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]; -- 2.7.4