Rebase against aba27fd5a3241635adb15fa7ef40aa43bf3978a1.

This commit is contained in:
Zebediah Figura
2020-06-04 00:08:14 -05:00
parent 0db92c336f
commit 7b78338b07
13 changed files with 185 additions and 187 deletions

View File

@@ -1,4 +1,4 @@
From 5f34c6a4429025ee71616e677e0e59342bee17b0 Mon Sep 17 00:00:00 2001
From 9da818bd948256572640e17766a14a72e58ce100 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Wed, 25 Feb 2015 22:45:42 +0100
Subject: [PATCH] ntdll: Fix race-condition when threads are killed during
@@ -15,22 +15,15 @@ only be executed safely when all other threads have terminated before. Most
likely there are more Wine bugs in this area, but the attached patch should
fix the most critical one (messed up refcounting of threads) for now.
---
dlls/ntdll/thread.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
dlls/ntdll/thread.c | 2 +-
dlls/ntdll/unix/thread.c | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index bb11521cf69..fee26ccd21d 100644
index d5e34cae3b1..83237b3569a 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -298,6 +298,7 @@ TEB *thread_init(void)
void WINAPI RtlExitUserThread( ULONG status )
{
static void *prev_teb;
+ sigset_t sigset;
TEB *teb;
if (status) /* send the exit code to the server (0 is already the default) */
@@ -311,7 +312,7 @@ void WINAPI RtlExitUserThread( ULONG status )
@@ -295,7 +295,7 @@ void WINAPI RtlExitUserThread( ULONG status )
SERVER_END_REQ;
}
@@ -39,16 +32,29 @@ index bb11521cf69..fee26ccd21d 100644
{
LdrShutdownProcess();
unix_funcs->exit_process( status );
@@ -333,6 +334,11 @@ void WINAPI RtlExitUserThread( ULONG status )
diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c
index 205a1312e92..563712bd59e 100644
--- a/dlls/ntdll/unix/thread.c
+++ b/dlls/ntdll/unix/thread.c
@@ -219,6 +219,7 @@ void CDECL abort_thread( int status )
void CDECL exit_thread( int status )
{
static void *prev_teb;
+ sigset_t sigset;
TEB *teb;
pthread_sigmask( SIG_BLOCK, &server_block_set, NULL );
@@ -233,6 +234,12 @@ void CDECL exit_thread( int status )
virtual_free_teb( teb );
}
}
+
+ sigemptyset( &sigset );
+ sigaddset( &sigset, SIGQUIT );
+ pthread_sigmask( SIG_BLOCK, &sigset, NULL );
+ if (!InterlockedDecrement( &nb_threads )) _exit( status );
+ if (!InterlockedDecrement( nb_threads )) _exit( status );
+
for (;;) unix_funcs->exit_thread( status );
signal_exit_thread( status, pthread_exit_wrapper );
}
--