summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-03-27 09:10:57 -0400
committerBen Gamari <ben@smart-cactus.org>2021-03-29 16:18:48 -0400
commitd8c5576f49ef834f10b610e3ae954fa461d5fa1a (patch)
tree7e7760487d894fb4c721f2e8a83a487b0ee25f1f
parent844392117c10d7b0cf26483e4cb97783388bc0db (diff)
downloadhaskell-d8c5576f49ef834f10b610e3ae954fa461d5fa1a.tar.gz
rts: Fix joinOSThread on Windows
Previously we were treating the thread ID as a HANDLE, but it is not. We must first OpenThread. (cherry picked from commit 63a5c876657bb89e9847f325fb81df2229297eb3)
-rw-r--r--rts/win32/OSThreads.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/rts/win32/OSThreads.c b/rts/win32/OSThreads.c
index 07b0e3f034..46e363b3ab 100644
--- a/rts/win32/OSThreads.c
+++ b/rts/win32/OSThreads.c
@@ -447,7 +447,12 @@ interruptOSThread (OSThreadId id)
void
joinOSThread (OSThreadId id)
{
- int ret = WaitForSingleObject(id, INFINITE);
+ HANDLE hdl;
+ if (!(hdl = OpenThread(SYNCHRONIZE,FALSE,id))) {
+ sysErrorBelch("interruptOSThread: OpenThread");
+ stg_exit(EXIT_FAILURE);
+ }
+ int ret = WaitForSingleObject(hdl, INFINITE);
if (ret != WAIT_OBJECT_0) {
sysErrorBelch("joinOSThread: error %d", ret);
}