(putting patch in subject )

Hi

We have an internal bug that happens when closing the application where there is a legacy format document ( e.g. something.sdd ) already open

I get the following trace

==23824== Invalid read of size 8
==23824== at 0x10C543A0: GtkSalDisplay::EventGuardAcquire() (gtkdata.hxx:83)
==23824==    by 0x10C53633: GtkXLib::userEventFn(void*) (gtkdata.cxx:800)
==23824==    by 0x10C535D4: call_userEventFn (gtkdata.cxx:789)
==23824== by 0x13538BD2: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2800.0)
==23824==    by 0x135393AF: ??? (in /lib64/libglib-2.0.so.0.2800.0)
==23824== by 0x1353964F: g_main_context_iteration (in /lib64/libglib-2.0.so.0.2800.0)
==23824==    by 0x10C53861: GtkXLib::Yield(bool, bool) (gtkdata.cxx:868)
==23824==    by 0x10C5294A: GtkXLib::~GtkXLib() (gtkdata.cxx:577)
==23824==    by 0x10C52A37: GtkXLib::~GtkXLib() (gtkdata.cxx:587)
==23824==    by 0x1392F225: X11SalData::DeleteDisplay() (saldata.cxx:293)
==23824==    by 0x1392F108: X11SalData::~X11SalData() (saldata.cxx:286)
==23824==    by 0x10C53CEB: GtkData::~GtkData() (gtkdata.cxx:1032)
==23824== Address 0x16002a00 is 576 bytes inside a block of size 2,296 free'd ==23824== at 0x4C2599C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==23824== by 0x10C50897: GtkSalDisplay::~GtkSalDisplay() (gtkdata.cxx:110)
==23824==    by 0x1392F1ED: X11SalData::DeleteDisplay() (saldata.cxx:291)
==23824==    by 0x1392F108: X11SalData::~X11SalData() (saldata.cxx:286)
==23824==    by 0x10C53CEB: GtkData::~GtkData() (gtkdata.cxx:1032)
==23824==    by 0x10C53D1D: GtkData::~GtkData() (gtkdata.cxx:1034)
==23824== by 0x139443E5: X11SalInstance::~X11SalInstance() (salinst.cxx:141)
==23824==    by 0x10C55F5D: GtkInstance::~GtkInstance() (gtkinst.cxx:187)
==23824==    by 0x10C55FB1: GtkInstance::~GtkInstance() (gtkinst.cxx:190)
==23824== by 0x99EB564: DestroySalInstance(SalInstance*) (salplug.cxx:264)
==23824==    by 0x960A5C9: DeInitVCL() (svmain.cxx:566)
==23824==    by 0x96094F0: ImplSVMain() (svmain.cxx:198)

I had a patch ( that just returned immediately from GtkXLib::userEventFn while GtkXLib was destructing ) However now I see that this doesn't happen on master so after looking there I rewrote the patch be more like ( albeit simpler ) the solution there ( which seems to be part of some bigger rework, for gtk3 ? )

attached is the patch, 2 version, one generated ingnoring whitespace ( for ease of review ) the other with whitespace for applying

since I know approximately zero about gtk stuff, appreciate wiser heads having a look

thanks,
Noel


diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx
index 6a61098..7c76d6f 100644
--- a/vcl/unx/gtk/app/gtkdata.cxx
+++ b/vcl/unx/gtk/app/gtkdata.cxx
@@ -792,30 +792,36 @@ extern "C"
 
 gboolean GtkXLib::userEventFn(gpointer data)
 {
-    gboolean bContinue;
+   
+    gboolean bContinue = FALSE;
     GtkXLib *pThis = (GtkXLib *) data;
-    SalData *pSalData = GetSalData();
 
-    pSalData->m_pInstance->GetYieldMutex()->acquire();
-    pThis->m_pGtkSalDisplay->EventGuardAcquire();
+    GtkData *pGtkData = static_cast<GtkData*>(GetSalData());
+
+    pGtkData->m_pInstance->GetYieldMutex()->acquire();
 
-    if( !pThis->m_pGtkSalDisplay->HasMoreEvents() )
+    if ( pGtkData->GetDisplay() )
     {
-        if( pThis->m_pUserEvent )
+        pThis->m_pGtkSalDisplay->EventGuardAcquire();
+
+        if( !pThis->m_pGtkSalDisplay->HasMoreEvents() )
         {
-            g_source_unref (pThis->m_pUserEvent);
-            pThis->m_pUserEvent = NULL;
+            if( pThis->m_pUserEvent )
+            {
+                g_source_unref (pThis->m_pUserEvent);
+                pThis->m_pUserEvent = NULL;
+            }
+            bContinue = FALSE;
         }
-        bContinue = FALSE;
-    }
-    else
-        bContinue = TRUE;
+        else
+            bContinue = TRUE;
 
-    pThis->m_pGtkSalDisplay->EventGuardRelease();
+        pThis->m_pGtkSalDisplay->EventGuardRelease();
 
-    pThis->m_pGtkSalDisplay->DispatchInternalEvent();
+        pThis->m_pGtkSalDisplay->DispatchInternalEvent();
 
-    pSalData->m_pInstance->GetYieldMutex()->release();
+        pGtkData->m_pInstance->GetYieldMutex()->release();
+    }
 
     return bContinue;
 }


diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx
index 6a61098..7c76d6f 100644
--- a/vcl/unx/gtk/app/gtkdata.cxx
+++ b/vcl/unx/gtk/app/gtkdata.cxx
@@ -792,11 +792,16 @@ extern "C"
 
 gboolean GtkXLib::userEventFn(gpointer data)
 {
-    gboolean bContinue;
+   
+    gboolean bContinue = FALSE;
     GtkXLib *pThis = (GtkXLib *) data;
-    SalData *pSalData = GetSalData();
 
-    pSalData->m_pInstance->GetYieldMutex()->acquire();
+    GtkData *pGtkData = static_cast<GtkData*>(GetSalData());
+
+    pGtkData->m_pInstance->GetYieldMutex()->acquire();
+
+    if ( pGtkData->GetDisplay() )
+    {
     pThis->m_pGtkSalDisplay->EventGuardAcquire();
 
     if( !pThis->m_pGtkSalDisplay->HasMoreEvents() )
@@ -815,7 +820,8 @@ gboolean GtkXLib::userEventFn(gpointer data)
 
     pThis->m_pGtkSalDisplay->DispatchInternalEvent();
 
-    pSalData->m_pInstance->GetYieldMutex()->release();
+        pGtkData->m_pInstance->GetYieldMutex()->release();
+    }
 
     return bContinue;
 }


_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to