9facfb9
From ad313992da1cf89f5825a4d1eb020392b5e32c6d Mon Sep 17 00:00:00 2001
9facfb9
From: Stephan Bergmann <sbergman@redhat.com>
9facfb9
Date: Tue, 19 Mar 2019 17:29:53 +0100
9facfb9
Subject: [PATCH] rhbz#1687589: KDE4 gpoll_wrapper can be called with
9facfb9
 SolarMutex unlocked
9facfb9
9facfb9
...when called from MountOperation::Mount (ucb/source/ucp/gio/gio_content.cxx),
9facfb9
which itself contains a SolarMutexReleaser since
9facfb9
2eb36dc4b846ab5886ae71fd2978b56b2a2d1d08 "Hack to not leave SolarMutex released
9facfb9
after g_main_loop_run call".  So calling SolarMutexReleaser ctor in
9facfb9
gpoll_wrapper will then cause comphelper::GenericSolarMutex::doRelease
9facfb9
(comphelper/source/misc/solarmutex.cxx) to call std::abort() because the
9facfb9
SolarMutex is not locked.
9facfb9
9facfb9
Change-Id: If893b427e404cf3d9e48430f84cff7d32b61bf87
9facfb9
Reviewed-on: https://gerrit.libreoffice.org/69436
9facfb9
Tested-by: Jenkins
9facfb9
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
9facfb9
---
9facfb9
 vcl/unx/kde4/KDEXLib.cxx | 11 +++++++++--
9facfb9
 1 file changed, 9 insertions(+), 2 deletions(-)
9facfb9
9facfb9
diff --git a/vcl/unx/kde4/KDEXLib.cxx b/vcl/unx/kde4/KDEXLib.cxx
9facfb9
index 0852c543a6d7..22274690842b 100644
9facfb9
--- a/vcl/unx/kde4/KDEXLib.cxx
9facfb9
+++ b/vcl/unx/kde4/KDEXLib.cxx
9facfb9
@@ -210,8 +210,15 @@ static GPollFunc old_gpoll = nullptr;
9facfb9
 
9facfb9
 static gint gpoll_wrapper( GPollFD* ufds, guint nfds, gint timeout )
9facfb9
 {
9facfb9
-    SolarMutexReleaser aReleaser;
9facfb9
-    return old_gpoll( ufds, nfds, timeout );
9facfb9
+    if (GetSalData()->m_pInstance->GetYieldMutex()->IsCurrentThread())
9facfb9
+    {
9facfb9
+        SolarMutexReleaser aReleaser;
9facfb9
+        return old_gpoll( ufds, nfds, timeout );
9facfb9
+    }
9facfb9
+    else
9facfb9
+    {
9facfb9
+        return old_gpoll( ufds, nfds, timeout );
9facfb9
+    }
9facfb9
 }
9facfb9
 #endif
9facfb9
 
9facfb9
-- 
9facfb9
2.20.1
9facfb9