Torge Matthies : winex11.drv: Avoid race condition in X11 error handling.
Alexandre Julliard
julliard at winehq.org
Tue Oct 26 09:40:29 CDT 2021
Module: wine
Branch: stable
Commit: 96a1855bb92d8ee080f3505245f1fda3368ebf70
URL: https://source.winehq.org/git/wine.git/?a=commit;h=96a1855bb92d8ee080f3505245f1fda3368ebf70
Author: Torge Matthies <openglfreak at googlemail.com>
Date: Mon Jun 7 01:05:16 2021 +0200
winex11.drv: Avoid race condition in X11 error handling.
The err_callback* globals need to be protected from being overwritten
before X11DRV_check_error is called, otherwise no or the wrong error
handler might be called.
Signed-off-by: Torge Matthies <openglfreak at googlemail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 2e4bfa642e31f9690365d6daf42ef87a74331cf7)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/winex11.drv/x11drv_main.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index 9ec4c7a98f6..2fac560556b 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -108,6 +108,15 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
};
static CRITICAL_SECTION x11drv_section = { &critsect_debug, -1, 0, 0, 0, 0 };
+static CRITICAL_SECTION x11drv_error_section;
+static CRITICAL_SECTION_DEBUG x11drv_error_section_debug =
+{
+ 0, 0, &x11drv_error_section,
+ { &x11drv_error_section_debug.ProcessLocksList, &x11drv_error_section_debug.ProcessLocksList },
+ 0, 0, { (DWORD_PTR)(__FILE__ ": x11drv_error_section") }
+};
+static CRITICAL_SECTION x11drv_error_section = { &x11drv_error_section_debug, -1, 0, 0, 0, 0 };
+
struct d3dkmt_vidpn_source
{
D3DKMT_VIDPNSOURCEOWNER_TYPE type; /* VidPN source owner type */
@@ -256,6 +265,7 @@ static inline BOOL ignore_error( Display *display, XErrorEvent *event )
*/
void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void *arg )
{
+ EnterCriticalSection( &x11drv_error_section );
err_callback = callback;
err_callback_display = display;
err_callback_arg = arg;
@@ -272,8 +282,10 @@ void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void
*/
int X11DRV_check_error(void)
{
+ int res = err_callback_result;
err_callback = NULL;
- return err_callback_result;
+ LeaveCriticalSection( &x11drv_error_section );
+ return res;
}
More information about the wine-cvs
mailing list