cui/source/options/personalization.cxx | 14 +++++++++++--- cui/source/options/personalization.hxx | 4 +++- 2 files changed, 14 insertions(+), 4 deletions(-)
New commits: commit ec8e973f7e681b0ae25e4b781918dd98ea0e8176 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Mon Jun 4 16:28:22 2018 +0200 tdf#117866 cui: avoid deadlock in personalization dialog The deadlock happened as the main thread wanted to join SearchAndParseThread (while owning the solar mutex), but SearchAndParseThread wanted to take the solar mutex to import a graphic. Fix the deadlock by checking for the termination flag earlier, so we don't take any new mutexes if termination was requested already. (cherry picked from commit 766c85a4f67f5d50645340e31cebd5956998c6fc) Related: tdf#117866 cui: use std::atomic for thread termination flag (cherry picked from commit f4ac7b5a084a7cf483bb89a2fa411f9df70df4d0) tdf#117866 cui personalization: fix a possible race The case when the thread is re-scheduled exactly after checking for m_bExecute but before taking the solar mutex. (cherry picked from commit f4c73f90da2a2c31f0d29572180aa97e10c3dbad) Change-Id: Idddaadadc693610d9f31a14300b22aff8d452756 Reviewed-on: https://gerrit.libreoffice.org/55347 Reviewed-by: Luboš Luňák <l.lu...@collabora.com> Tested-by: Jenkins diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx index a9ff29edf078..dab788d8b824 100644 --- a/cui/source/options/personalization.cxx +++ b/cui/source/options/personalization.cxx @@ -99,7 +99,13 @@ SelectPersonaDialog::~SelectPersonaDialog() void SelectPersonaDialog::dispose() { if (m_pSearchThread.is()) + { + // Release the solar mutex, so the thread is not affected by the race + // when it's after the m_bExecute check but before taking the solar + // mutex. + SolarMutexReleaser aReleaser; m_pSearchThread->join(); + } m_pEdit.clear(); m_pSearchButton.clear(); @@ -772,14 +778,16 @@ void SearchAndParseThread::execute() continue; } INetURLObject aURLObj( sPreviewFile ); + + // Stop the thread if requested -- before taking the solar mutex. + if( !m_bExecute ) + return; + // for VCL to be able to create bitmaps / do visual changes in the thread SolarMutexGuard aGuard; aFilter.ImportGraphic( aGraphic, aURLObj ); Bitmap aBmp = aGraphic.GetBitmap(); - if( !m_bExecute ) - return; - m_pPersonaDialog->SetImages( Image( aBmp ), nIndex++ ); m_pPersonaDialog->setOptimalLayoutSize(); m_pPersonaDialog->AddPersonaSetting( aPersonaSetting ); diff --git a/cui/source/options/personalization.hxx b/cui/source/options/personalization.hxx index 9d5e057c8c34..5153fc98b1b5 100644 --- a/cui/source/options/personalization.hxx +++ b/cui/source/options/personalization.hxx @@ -16,6 +16,7 @@ #include <vcl/prgsbar.hxx> #include <vector> #include <array> +#include <atomic> #define CATEGORYCOUNT 6 // Number of persona categories @@ -119,7 +120,8 @@ private: VclPtr<SelectPersonaDialog> m_pPersonaDialog; OUString m_aURL; - bool m_bExecute, m_bDirectURL; + std::atomic<bool> m_bExecute; + bool m_bDirectURL; virtual ~SearchAndParseThread() override; virtual void execute() override; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits