Skip to content

Commit 4a8bdea

Browse files
committed
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.
1 parent 76942bb commit 4a8bdea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/vm/win32threadpool.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1191,10 +1191,10 @@ class ThreadpoolMgr
11911191
ULONG count)
11921192
{
11931193
LIMITED_METHOD_CONTRACT;
1194-
memcpy(&threadCB->waitHandle[DestIndex],
1194+
memmove(&threadCB->waitHandle[DestIndex],
11951195
&threadCB->waitHandle[SrcIndex],
11961196
count * sizeof(HANDLE));
1197-
memcpy(&threadCB->waitPointer[DestIndex],
1197+
memmove(&threadCB->waitPointer[DestIndex],
11981198
&threadCB->waitPointer[SrcIndex],
11991199
count * sizeof(LIST_ENTRY));
12001200
}

0 commit comments

Comments
 (0)