[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - pyuno/source

Michael Stahl mstahl at redhat.com
Thu Aug 28 08:53:24 PDT 2014


 pyuno/source/module/pyuno_runtime.cxx |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

New commits:
commit f919c2c441a88837f3a85b90011ea3d91041f4bb
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Aug 28 15:11:37 2014 +0200

    fdo#46678: pyuno: fix deadlock in Runtime::any2PyObject()
    
    When calling XUnoTunnel::getSomething(), the function must drop the
    CPython GIL to avoid deadlock since there are implementations of
    XUnoTunnel that acquire SolarMutex.
    
    Change-Id: I51ffce9bdee9a51c932902e77856f865eae81d2a
    (cherry picked from commit 0364d3b7e670bddb49d5132268cf28737c3301c6)
    Reviewed-on: https://gerrit.libreoffice.org/11178
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
    Tested-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/pyuno/source/module/pyuno_runtime.cxx b/pyuno/source/module/pyuno_runtime.cxx
index 93c6020..e348b2d 100644
--- a/pyuno/source/module/pyuno_runtime.cxx
+++ b/pyuno/source/module/pyuno_runtime.cxx
@@ -562,13 +562,19 @@ PyRef Runtime::any2PyObject (const Any &a ) const
     }
     case typelib_TypeClass_INTERFACE:
     {
-        Reference< XUnoTunnel > tunnel;
-        a >>= tunnel;
-        if( tunnel.is() )
+        // fdo#46678 must unlock GIL because getSomething could acquire locks,
+        // and queryInterface too...
         {
-            sal_Int64 that = tunnel->getSomething( ::pyuno::Adapter::getUnoTunnelImplementationId() );
-            if( that )
-                return ((Adapter*)sal::static_int_cast< sal_IntPtr >(that))->getWrappedObject();
+            PyThreadDetach d;
+
+            Reference<XUnoTunnel> tunnel;
+            a >>= tunnel;
+            if (tunnel.is())
+            {
+                sal_Int64 that = tunnel->getSomething( ::pyuno::Adapter::getUnoTunnelImplementationId() );
+                if( that )
+                    return ((Adapter*)sal::static_int_cast< sal_IntPtr >(that))->getWrappedObject();
+            }
         }
         //This is just like the struct case:
         return PyRef( PyUNO_new (a, getImpl()->cargo->xInvocation), SAL_NO_ACQUIRE );


More information about the Libreoffice-commits mailing list