[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - include/o3tl

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 4 07:36:30 UTC 2019


 include/o3tl/lru_map.hxx |    8 ++++++++
 1 file changed, 8 insertions(+)

New commits:
commit 4abdaf4afb2245d404f6709124b3c627b07b8a3c
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jun 3 16:07:40 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jun 4 09:35:47 2019 +0200

    fix crash in lru_map/SalBitmap on shutdown
    
    When we shut down, we destroy the various caches, in the process of
    which SalBitmap calls back into it's owning cache, causing a SIGSEGV.
    
    Found while loading files from tdf#83426
    
    Change-Id: I53db1621a0fdb75a8e66582662b0e2666499192b
    Reviewed-on: https://gerrit.libreoffice.org/73387
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    (cherry picked from commit c27e92b29efe573e2cda9844e9ca38965f502443)
    Reviewed-on: https://gerrit.libreoffice.org/73415

diff --git a/include/o3tl/lru_map.hxx b/include/o3tl/lru_map.hxx
index 003da59551b5..54378a319ece 100644
--- a/include/o3tl/lru_map.hxx
+++ b/include/o3tl/lru_map.hxx
@@ -69,6 +69,14 @@ public:
     lru_map(size_t nMaxSize)
         : mMaxSize(nMaxSize ? nMaxSize : std::min(mLruMap.max_size(), mLruList.max_size()))
     {}
+    ~lru_map()
+    {
+        // Some code .e.g. SalBitmap likes to remove itself from a cache during it's destructor, which means we
+        // get calls into lru_map while we are in destruction, so use the swap-and-clear idiom to avoid those problems.
+        mLruMap.clear();
+        list_t aLruListTemp;
+        aLruListTemp.swap(mLruList);
+    }
 
     void insert(key_value_pair_t& rPair)
     {


More information about the Libreoffice-commits mailing list