forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wine-1.7.38-gstreamer-v5-staging-post.patch
58 lines (50 loc) · 2.14 KB
/
wine-1.7.38-gstreamer-v5-staging-post.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From 695c19cdd2fc24aaa7ed89976c4965b376707131 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <[email protected]>
Date: Wed, 25 Feb 2015 22:45:42 +0100
Subject: ntdll: Fix race-condition when threads are killed during shutdown.
When exit_thread is executed, nb_threads is decremented before the thread is
fully shutdown. When another thread runs ExitProcess() this will cause a SIGQUIT
signal to all threads, effectively decrementing nb_threads twice. The process
will terminate with a wrong exitcode then because the refcount reaches zero too
early.
Currently Wine has no locking protection of LdrShutdownProcess(), so it can
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.
[Alexandre Rostovtsev <[email protected]> : rebase to be applied after
Maarten Lankhorst's "override pthreads to fix gstreamer v5" patch.]
---
dlls/ntdll/thread.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 4f181dc..1bdbcbf 100755
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -461,6 +461,7 @@ static void exit_thread_common( int status )
static void *prev_teb;
TEB *teb;
#endif
+ sigset_t sigset;
if (status) /* send the exit code to the server (0 is already the default) */
{
@@ -473,7 +474,7 @@ static void exit_thread_common( int status )
SERVER_END_REQ;
}
- if (interlocked_xchg_add( &nb_threads, -1 ) <= 1)
+ if (interlocked_xchg_add( &nb_threads, 0 ) <= 1)
{
LdrShutdownProcess();
exit( status );
@@ -499,6 +500,11 @@ static void exit_thread_common( int status )
reap_thread(NtCurrentTeb());
#endif
+ sigemptyset( &sigset );
+ sigaddset( &sigset, SIGQUIT );
+ pthread_sigmask( SIG_BLOCK, &sigset, NULL );
+ if (interlocked_xchg_add( &nb_threads, -1 ) <= 1) _exit( status );
+
close( ntdll_get_thread_data()->wait_fd[0] );
close( ntdll_get_thread_data()->wait_fd[1] );
close( ntdll_get_thread_data()->reply_fd );
--
2.3.1