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 11:51:39 -0400
commit37382dd03caef049bfc5018c4358f2fc42119c5e (patch)
tree2060aebcea1ebea8947e9b3eae88767f63d3b594
parentd6cd2055b4bdc5dc97eeebbd24a0e159dd572420 (diff)
downloadhaskell-37382dd03caef049bfc5018c4358f2fc42119c5e.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 0ef2a7e293..4efd9b5449 100644
--- a/rts/win32/OSThreads.c
+++ b/rts/win32/OSThreads.c
@@ -585,7 +585,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);
}