[PATCH 0/2] MR9349: win32u: Fix deadlock caused by nested locking.
Convert surface lock to recursive mutex to allow same thread to acquire the lock multiple times, preventing deadlocks when lock_surface() and window_surface_lock() are called nestedly. Signed-off-by: Zhao Yi <zhaoyi(a)uniontech.com> -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9349
From: Zhao Yi <zhaoyi(a)uniontech.com> Convert surface lock to recursive mutex to allow same thread to acquire the lock multiple times, preventing deadlocks when lock_surface() and window_surface_lock() are called nestedly. Signed-off-by: Zhao Yi <zhaoyi(a)uniontech.com> --- dlls/win32u/dce.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index 6ba5f1c7c44..6c7e49b2976 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -528,6 +528,7 @@ W32KAPI struct window_surface *window_surface_create( UINT size, const struct wi const RECT *rect, BITMAPINFO *info, HBITMAP bitmap ) { struct window_surface *surface; + pthread_mutexattr_t attr; if (!(surface = calloc( 1, size ))) return NULL; surface->funcs = funcs; @@ -546,7 +547,10 @@ W32KAPI struct window_surface *window_surface_create( UINT size, const struct wi return NULL; } - pthread_mutex_init( &surface->mutex, NULL ); + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); + pthread_mutex_init( &surface->mutex, &attr ); + pthread_mutexattr_destroy(&attr); TRACE( "created surface %p for hwnd %p rect %s\n", surface, hwnd, wine_dbgstr_rect( &surface->rect ) ); return surface; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9349
From: Zhao Yi <zhaoyi(a)uniontech.com> Signed-off-by: Zhao Yi <zhaoyi(a)uniontech.com> --- dlls/shell32/cpanelfolder.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dlls/shell32/cpanelfolder.c b/dlls/shell32/cpanelfolder.c index 69af6734f57..f611ced3c1c 100644 --- a/dlls/shell32/cpanelfolder.c +++ b/dlls/shell32/cpanelfolder.c @@ -131,7 +131,8 @@ HRESULT WINAPI IControlPanel_Constructor(IUnknown* pUnkOuter, REFIID riid, LPVOI sf->pUnkOuter = pUnkOuter ? pUnkOuter : (IUnknown *)&sf->IShellFolder2_iface; if (FAILED(IShellFolder2_QueryInterface(&sf->IShellFolder2_iface, riid, ppv))) { - IShellFolder2_Release(&sf->IShellFolder2_iface); + SHFree(sf->pidlRoot); + LocalFree(sf); return E_NOINTERFACE; } IShellFolder2_Release(&sf->IShellFolder2_iface); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9349
This merge request was closed by Zhao Yi. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9349
participants (2)
-
Zhao Yi -
Zhao Yi (@Zhaoyi)