[Libreoffice-commits] core.git: sc/source

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Mon Nov 30 12:18:08 UTC 2020


 sc/source/core/data/documen2.cxx |    2 +-
 sc/source/core/data/documen8.cxx |    5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

New commits:
commit cb25771fedd12725a72a1eb4f532698d8221c0f2
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Nov 27 11:25:40 2020 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Mon Nov 30 13:17:18 2020 +0100

    it does not work to clear data of other thread's thread_local
    
    The thread-specific RecursionHelper object is reused between runs,
    so it should not be freed after a threaded calculation finishes.
    But since threads may be left around longer by the thread pool,
    the object may be destroyed at an unknown later time. Which could
    possibly cause problems if it refers to data that's been destroyed
    meanwhile (I think all the pointers in RecursionHelper are not
    owning, so this should not be a problem in practice, but still).
    So at least clear the contents, they shouldn't be reused anyway.
    
    Change-Id: I8934441c754d20bd20d7e19a8510d9323c0db894
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106758
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 60f62ae6587b..2e607a669896 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -387,7 +387,7 @@ ScDocument::~ScDocument()
 
     pScriptTypeData.reset();
     maNonThreaded.xRecursionHelper.reset();
-    maThreadSpecific.xRecursionHelper.reset();
+    assert(!maThreadSpecific.xRecursionHelper);
 
     pPreviewFont.reset();
     SAL_WARN_IF( pAutoNameCache, "sc.core", "AutoNameCache still set in dtor" );
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 03623e1c4c0e..dbedc986f93c 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -80,6 +80,7 @@
 #include <stringutil.hxx>
 #include <documentlinkmgr.hxx>
 #include <tokenarray.hxx>
+#include <recursionhelper.hxx>
 
 #include <memory>
 #include <utility>
@@ -420,6 +421,10 @@ const ScDocumentThreadSpecific& ScDocument::CalculateInColumnInThread( ScInterpr
 
     assert(IsThreadedGroupCalcInProgress());
     maThreadSpecific.pContext = nullptr;
+    // If any of the thread_local data would cause problems if they stay around for too long
+    // (and e.g. outlive the ScDocument), clean them up here, they cannot be cleaned up
+    // later from the main thread.
+    maThreadSpecific.xRecursionHelper->Clear();
 
     return maThreadSpecific;
 }


More information about the Libreoffice-commits mailing list