From 4a8bdea12fca5d5889ce1e264d27cabc1e10ebf8 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Thu, 19 Nov 2015 09:16:34 +0100 Subject: Fix issue with threadpool and wait for multiple objects on Linux There is a method ThreadpoolMgr::ShiftWaitArray which uses memcpy to do a move a segment of the waitPointer and waitHandle arrays one position down, so the source and destination ranges overlap. However, it uses memcpy, which on Linux copies items starting from the last one. So the arrays get corrupted after the memcpy, containing multiple copies of the last element and not containig some elements that were expected to move. The fix is to use memmove which should be used when the source and destination memory regions overlap. --- src/vm/win32threadpool.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/vm') diff --git a/src/vm/win32threadpool.h b/src/vm/win32threadpool.h index 22fd6e05b4..f29c0bd954 100644 --- a/src/vm/win32threadpool.h +++ b/src/vm/win32threadpool.h @@ -1191,10 +1191,10 @@ public: ULONG count) { LIMITED_METHOD_CONTRACT; - memcpy(&threadCB->waitHandle[DestIndex], + memmove(&threadCB->waitHandle[DestIndex], &threadCB->waitHandle[SrcIndex], count * sizeof(HANDLE)); - memcpy(&threadCB->waitPointer[DestIndex], + memmove(&threadCB->waitPointer[DestIndex], &threadCB->waitPointer[SrcIndex], count * sizeof(LIST_ENTRY)); } -- cgit v1.2.3