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-04-07 15:56:43 -0400
commitb3aad8b96bee59fecb8fee39e3b45a16e655cdda (patch)
tree22249f1ad035d57097bd680b2bd08b465bca9f67
parentb741f47ff493ca0b48ba1c9785b6269f7e962e5d (diff)
downloadhaskell-b3aad8b96bee59fecb8fee39e3b45a16e655cdda.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 b738c80f58..17fa95d8a2 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);
}