Added patches to fix race-condition when closing browseui IProcessDialog.

This commit is contained in:
Sebastian Lackner 2015-03-01 04:10:54 +01:00
parent 67e8c4d0a9
commit 6cf3424356
4 changed files with 177 additions and 31 deletions

1
debian/changelog vendored
View File

@ -28,6 +28,7 @@ wine-staging (1.7.38) UNRELEASED; urgency=low
* Added patch to fix crash in clip_cursor_notify caused by uninitialized TLS.
* Added patches to make various functions in d3d8 / ddraw hotpatchable (required for fraps).
* Added patch to make GetLogicalProcessorInformationEx a stub which returns TRUE.
* Added patches to fix race-condition when closing browseui IProcessDialog.
* Removed patch to properly call DriverUnload when unloading device drivers (accepted upstream).
* Removed patch to allow Accept-Encoding for HTTP/1.0 in wininet (accepted upstream).
* Removed patch to declare pDirectInputCreateEx in a MSVC compatible way (accepted upstream).

View File

@ -0,0 +1,79 @@
From d8497e4ebc1fb5a3b703e4dd4474c65bbb25796d Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 1 Mar 2015 03:46:06 +0100
Subject: browseui: Always use interlocked functions when accessing variable
BROWSEUI_refCount.
---
dlls/browseui/browseui_main.c | 4 ++--
dlls/browseui/compcatcachedaemon.c | 4 ++--
dlls/browseui/progressdlg.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/browseui/browseui_main.c b/dlls/browseui/browseui_main.c
index 78ce326..f509ee5 100644
--- a/dlls/browseui/browseui_main.c
+++ b/dlls/browseui/browseui_main.c
@@ -74,7 +74,7 @@ static void ClassFactory_Destructor(ClassFactory *This)
{
TRACE("Destroying class factory %p\n", This);
heap_free(This);
- BROWSEUI_refCount--;
+ InterlockedDecrement(&BROWSEUI_refCount);
}
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppvOut)
@@ -154,7 +154,7 @@ static HRESULT ClassFactory_Constructor(LPFNCONSTRUCTOR ctor, LPVOID *ppvOut)
This->ctor = ctor;
*ppvOut = This;
TRACE("Created class factory %p\n", This);
- BROWSEUI_refCount++;
+ InterlockedIncrement(&BROWSEUI_refCount);
return S_OK;
}
diff --git a/dlls/browseui/compcatcachedaemon.c b/dlls/browseui/compcatcachedaemon.c
index 0acb4ec..a5addd2 100644
--- a/dlls/browseui/compcatcachedaemon.c
+++ b/dlls/browseui/compcatcachedaemon.c
@@ -60,7 +60,7 @@ static void CompCatCacheDaemon_Destructor(CompCatCacheDaemon *This)
This->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->cs);
heap_free(This);
- BROWSEUI_refCount--;
+ InterlockedDecrement(&BROWSEUI_refCount);
}
static HRESULT WINAPI CompCatCacheDaemon_QueryInterface(IRunnableTask *iface, REFIID iid, LPVOID *ppvOut)
@@ -159,6 +159,6 @@ HRESULT CompCatCacheDaemon_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
TRACE("returning %p\n", This);
*ppOut = (IUnknown *)This;
- BROWSEUI_refCount++;
+ InterlockedIncrement(&BROWSEUI_refCount);
return S_OK;
}
diff --git a/dlls/browseui/progressdlg.c b/dlls/browseui/progressdlg.c
index 598197b..e61a4cc 100644
--- a/dlls/browseui/progressdlg.c
+++ b/dlls/browseui/progressdlg.c
@@ -268,7 +268,7 @@ static void ProgressDialog_Destructor(ProgressDialog *This)
This->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->cs);
heap_free(This);
- BROWSEUI_refCount--;
+ InterlockedDecrement(&BROWSEUI_refCount);
}
static HRESULT WINAPI ProgressDialog_QueryInterface(IProgressDialog *iface, REFIID iid, LPVOID *ppvOut)
@@ -574,6 +574,6 @@ HRESULT ProgressDialog_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
TRACE("returning %p\n", This);
*ppOut = (IUnknown *)This;
- BROWSEUI_refCount++;
+ InterlockedIncrement(&BROWSEUI_refCount);
return S_OK;
}
--
2.3.0

View File

@ -0,0 +1,48 @@
From da4415d947b792fc5e0de978cf22e68d2b6b8601 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 1 Mar 2015 03:52:06 +0100
Subject: browseui: Avoid race-conditions when progress dialog is released
before thread terminates.
---
dlls/browseui/progressdlg.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/dlls/browseui/progressdlg.c b/dlls/browseui/progressdlg.c
index e61a4cc..7d07ee9 100644
--- a/dlls/browseui/progressdlg.c
+++ b/dlls/browseui/progressdlg.c
@@ -235,6 +235,7 @@ static DWORD WINAPI dialog_thread(LPVOID lpParameter)
/* Note: until we set the hEvent in WM_INITDIALOG, the ProgressDialog object
* is protected by the critical section held by StartProgress */
struct create_params *params = lpParameter;
+ ProgressDialog *This = params->This;
HWND hwnd;
MSG msg;
@@ -252,6 +253,7 @@ static DWORD WINAPI dialog_thread(LPVOID lpParameter)
}
}
+ IProgressDialog_Release(&This->IProgressDialog_iface);
return 0;
}
@@ -341,10 +343,14 @@ static HRESULT WINAPI ProgressDialog_StartProgressDialog(IProgressDialog *iface,
return S_OK; /* as on XP */
}
This->dwFlags = dwFlags;
+
params.This = This;
params.hwndParent = hwndParent;
params.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
+ /* thread holds one reference to ensure clean shutdown */
+ IProgressDialog_AddRef(&This->IProgressDialog_iface);
+
hThread = CreateThread(NULL, 0, dialog_thread, &params, 0, NULL);
WaitForSingleObject(params.hEvent, INFINITE);
CloseHandle(params.hEvent);
--
2.3.0

View File

@ -67,6 +67,7 @@ patch_enable_all ()
enable_Pipelight="$1"
enable_Staging="$1"
enable_browseui_Progress_Dialog="$1"
enable_browseui_Race_Conditions="$1"
enable_comctl32_LoadIconMetric="$1"
enable_configure_Absolute_RPATH="$1"
enable_d3d8_Hotpatch="$1"
@ -240,6 +241,9 @@ patch_enable ()
browseui-Progress_Dialog)
enable_browseui_Progress_Dialog="$2"
;;
browseui-Race_Conditions)
enable_browseui_Race_Conditions="$2"
;;
comctl32-LoadIconMetric)
enable_comctl32_LoadIconMetric="$2"
;;
@ -1237,6 +1241,20 @@ if test "$enable_browseui_Progress_Dialog" -eq 1; then
) >> "$patchlist"
fi
# Patchset browseui-Race_Conditions
# |
# | Modified files:
# | * dlls/browseui/browseui_main.c, dlls/browseui/compcatcachedaemon.c, dlls/browseui/progressdlg.c
# |
if test "$enable_browseui_Race_Conditions" -eq 1; then
patch_apply browseui-Race_Conditions/0001-browseui-Always-use-interlocked-functions-when-acces.patch
patch_apply browseui-Race_Conditions/0002-browseui-Avoid-race-conditions-when-progress-dialog-.patch
(
echo '+ { "Sebastian Lackner", "browseui: Always use interlocked functions when accessing variable BROWSEUI_refCount.", 1 },';
echo '+ { "Sebastian Lackner", "browseui: Avoid race-conditions when progress dialog is released before thread terminates.", 1 },';
) >> "$patchlist"
fi
# Patchset comctl32-LoadIconMetric
# |
# | This patchset fixes the following Wine bugs:
@ -2266,22 +2284,6 @@ if test "$enable_kernel32_Console_Handles" -eq 1; then
) >> "$patchlist"
fi
# Patchset kernel32-SetFileInformationByHandle
# |
# | Modified files:
# | * dlls/kernel32/file.c, dlls/ntdll/file.c, include/winbase.h, include/winternl.h
# |
if test "$enable_kernel32_SetFileInformationByHandle" -eq 1; then
patch_apply kernel32-SetFileInformationByHandle/0001-ntdll-Define-a-couple-more-information-classes.patch
patch_apply kernel32-SetFileInformationByHandle/0002-include-Declare-a-couple-more-file-information-class.patch
patch_apply kernel32-SetFileInformationByHandle/0003-kernel32-Implement-SetFileInformationByHandle.patch
(
echo '+ { "Michael Müller", "ntdll: Define a couple more information classes.", 1 },';
echo '+ { "Michael Müller", "include: Declare a couple more file information class structures.", 1 },';
echo '+ { "Michael Müller", "kernel32: Implement SetFileInformationByHandle.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-FileDispositionInformation
# |
# | This patchset fixes the following Wine bugs:
@ -2301,6 +2303,22 @@ if test "$enable_ntdll_FileDispositionInformation" -eq 1; then
) >> "$patchlist"
fi
# Patchset kernel32-SetFileInformationByHandle
# |
# | Modified files:
# | * dlls/kernel32/file.c, dlls/ntdll/file.c, include/winbase.h, include/winternl.h
# |
if test "$enable_kernel32_SetFileInformationByHandle" -eq 1; then
patch_apply kernel32-SetFileInformationByHandle/0001-ntdll-Define-a-couple-more-information-classes.patch
patch_apply kernel32-SetFileInformationByHandle/0002-include-Declare-a-couple-more-file-information-class.patch
patch_apply kernel32-SetFileInformationByHandle/0003-kernel32-Implement-SetFileInformationByHandle.patch
(
echo '+ { "Michael Müller", "ntdll: Define a couple more information classes.", 1 },';
echo '+ { "Michael Müller", "include: Declare a couple more file information class structures.", 1 },';
echo '+ { "Michael Müller", "kernel32: Implement SetFileInformationByHandle.", 1 },';
) >> "$patchlist"
fi
# Patchset kernel32-CopyFileEx
# |
# | This patchset fixes the following Wine bugs:
@ -3358,6 +3376,21 @@ if test "$enable_server_CreateProcess_ACLs" -eq 1; then
) >> "$patchlist"
fi
# Patchset server-OpenProcess
# |
# | This patchset fixes the following Wine bugs:
# | * [#37087] Return an error when trying to open a terminated process
# |
# | Modified files:
# | * server/process.c, server/process.h
# |
if test "$enable_server_OpenProcess" -eq 1; then
patch_apply server-OpenProcess/0001-server-Return-error-when-opening-a-terminating-proce.patch
(
echo '+ { "Michael Müller", "server: Return error when opening a terminating process.", 3 },';
) >> "$patchlist"
fi
# Patchset server-Misc_ACL
# |
# | This patchset fixes the following Wine bugs:
@ -3375,21 +3408,6 @@ if test "$enable_server_Misc_ACL" -eq 1; then
) >> "$patchlist"
fi
# Patchset server-OpenProcess
# |
# | This patchset fixes the following Wine bugs:
# | * [#37087] Return an error when trying to open a terminated process
# |
# | Modified files:
# | * server/process.c, server/process.h
# |
if test "$enable_server_OpenProcess" -eq 1; then
patch_apply server-OpenProcess/0001-server-Return-error-when-opening-a-terminating-proce.patch
(
echo '+ { "Michael Müller", "server: Return error when opening a terminating process.", 3 },';
) >> "$patchlist"
fi
# Patchset server-JobObjects
# |
# | This patchset fixes the following Wine bugs: