[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-5-2+backports' - 2 commits - svtools/source vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jan 30 14:25:10 UTC 2019


 svtools/source/misc/transfer.cxx |    4 ----
 vcl/unx/gtk3/gtk3gtkinst.cxx     |    7 ++++++-
 2 files changed, 6 insertions(+), 5 deletions(-)

New commits:
commit 23f4be51ddc410acb71634ca6c50ca52664dca86
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Jan 29 18:39:25 2019 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Wed Jan 30 15:06:44 2019 +0100

    vcl: fix deadlock in VclGtkClipboard::setContents()
    
    Must not call getTransferDataFlavors with m_Mutex held;
    
    6  TransferableHelper::getTransferDataFlavors() (this=0x567b980) at svtools/source/misc/transfer.cxx:392
    7  VclGtkClipboard::setContents(com::sun::star::uno::Reference<com::sun::star::datatransfer::XTransferable> const&, com::sun::star::uno::Reference<com::sun::star::datatransfer::clipboard::XClipboardOwner> const&) (this=0x3199550, xTrans=uno::Reference to (SwTransferable *) 0x567b9a8, xClipboardOwner=uno::Reference to (SwTransferable *) 0x567b9b0) at vcl/unx/gtk3_kde5/../gtk3/gtk3gtkinst.cxx:618
    8  TransferableHelper::CopyToSelection(vcl::Window*) const (this=0x567b980, pWindow=0x301b0c0) at svtools/source/misc/transfer.cxx:960
    
    CopyToSelection() uses SolarMutexReleaser, then getTransferDataFlavors()
    has a SolarMutexGuard; this will deadlock against the main thread
    that holds SolarMutex and calls VclGtkClipboard::setContents() itself,
    from VclGtkClipboard::OwnerPossiblyChanged().
    
    Change-Id: Ibda0b6bce6f3388c45cee8077dd977abb3dda366
    Reviewed-on: https://gerrit.libreoffice.org/67121
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    (cherry picked from commit 9286cebdff378a19ec146183676c6da96aac77db)

diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 7202b4681c8d..426cc235c5a9 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -597,6 +597,12 @@ void VclGtkClipboard::setContents(
         const Reference< css::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner )
     throw(RuntimeException, std::exception)
 {
+    css::uno::Sequence<css::datatransfer::DataFlavor> aFormats;
+    if (xTrans.is())
+    {
+        aFormats = xTrans->getTransferDataFlavors();
+    }
+
     osl::ClearableMutexGuard aGuard( m_aMutex );
     Reference< datatransfer::clipboard::XClipboardOwner > xOldOwner( m_aOwner );
     Reference< datatransfer::XTransferable > xOldContents( m_aContents );
@@ -615,7 +621,6 @@ void VclGtkClipboard::setContents(
     assert(m_aGtkTargets.empty());
     if (m_aContents.is())
     {
-        css::uno::Sequence<css::datatransfer::DataFlavor> aFormats = xTrans->getTransferDataFlavors();
         std::vector<GtkTargetEntry> aGtkTargets(m_aConversionHelper.FormatsToGtk(aFormats));
         if (!aGtkTargets.empty())
         {
commit 3ea2b2a7406f76754def5b7d321b25ca429562d8
Author:     Markus Mohrhard <markus.mohrhard at googlemail.com>
AuthorDate: Thu Jul 14 21:59:30 2016 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Wed Jan 30 15:06:44 2019 +0100

    try to avoid the deadlock around the clipboard, tdf#56818
    
    This deadlocks in the case that we have an external process
    communicating with LibreOffice as the SolarMutexReleaser allows a
    connection to be processed while the normal code has just released the
    SolarMutex. If the external call code now goes down the same code path
    we deadlock on the SolarMutex together with other mutexes in the
    clipboard code.
    
    Change-Id: I18fd6953c9566452a31b1a4c32c68494ec7a52ac
    Reviewed-on: https://gerrit.libreoffice.org/27251
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    (cherry picked from commit ed7e74ae1c7ecfc29df152a8397fb9f6e1763a60)

diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx
index f21d861d759f..fbfb9d2a4310 100644
--- a/svtools/source/misc/transfer.cxx
+++ b/svtools/source/misc/transfer.cxx
@@ -922,8 +922,6 @@ void TransferableHelper::CopyToClipboard( vcl::Window *pWindow ) const
 
     if( mxClipboard.is() && !mxTerminateListener.is() )
     {
-        SolarMutexReleaser aReleaser;
-
         try
         {
             TransferableHelper*                 pThis = const_cast< TransferableHelper* >( this );
@@ -949,8 +947,6 @@ void TransferableHelper::CopyToSelection( vcl::Window *pWindow ) const
 
     if( xSelection.is() && !mxTerminateListener.is() )
     {
-        SolarMutexReleaser aReleaser;
-
         try
         {
             TransferableHelper*                 pThis = const_cast< TransferableHelper* >( this );


More information about the Libreoffice-commits mailing list