comphelper/source/misc/compbase.cxx |    6 ++++++
 cppuhelper/source/compbase.cxx      |    6 ++++++
 cppuhelper/source/implbase_ex.cxx   |    6 ++++++
 3 files changed, 18 insertions(+)

New commits:
commit 7a283ee5540e42662b723ac08d3ea1a0e454045e
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Mon Feb 17 19:49:39 2025 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Mon Feb 17 22:10:38 2025 +0100

    Resolves: tdf#165295 partial cid#1555986 lock acquisition evasion revert
    
    seeing as getTypeEntries can be reentrant
    
    Change-Id: Ice119e2a48d4912722a35843bd1c5078805249bd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181799
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins

diff --git a/comphelper/source/misc/compbase.cxx 
b/comphelper/source/misc/compbase.cxx
index 02efae8b71c4..eafabb013937 100644
--- a/comphelper/source/misc/compbase.cxx
+++ b/comphelper/source/misc/compbase.cxx
@@ -97,6 +97,7 @@ static bool td_equals(typelib_TypeDescriptionReference const* 
pTDR1,
 static cppu::type_entry* getTypeEntries(cppu::class_data* cd)
 {
     cppu::type_entry* pEntries = cd->m_typeEntries;
+    if (!cd->m_storedTypeRefs) // not inited?
     {
         static std::mutex aMutex;
         std::scoped_lock guard(aMutex);
@@ -121,9 +122,14 @@ static cppu::type_entry* getTypeEntries(cppu::class_data* 
cd)
                 // ref is statically held by getCppuType()
                 pEntry->m_type.typeRef = rType.getTypeLibType();
             }
+            OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
             cd->m_storedTypeRefs = true;
         }
     }
+    else
+    {
+        OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+    }
     return pEntries;
 }
 
diff --git a/cppuhelper/source/compbase.cxx b/cppuhelper/source/compbase.cxx
index aca77677a0f4..ed4909b71106 100644
--- a/cppuhelper/source/compbase.cxx
+++ b/cppuhelper/source/compbase.cxx
@@ -81,6 +81,7 @@ static bool td_equals(typelib_TypeDescriptionReference const* 
pTDR1,
 static cppu::type_entry* getTypeEntries(cppu::class_data* cd)
 {
     cppu::type_entry* pEntries = cd->m_typeEntries;
+    if (!cd->m_storedTypeRefs) // not inited?
     {
         static std::mutex aMutex;
         std::scoped_lock guard(aMutex);
@@ -105,9 +106,14 @@ static cppu::type_entry* getTypeEntries(cppu::class_data* 
cd)
                 // ref is statically held by getCppuType()
                 pEntry->m_type.typeRef = rType.getTypeLibType();
             }
+            OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
             cd->m_storedTypeRefs = true;
         }
     }
+    else
+    {
+        OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+    }
     return pEntries;
 }
 
diff --git a/cppuhelper/source/implbase_ex.cxx 
b/cppuhelper/source/implbase_ex.cxx
index 9d3e03412737..3f88feb97dd1 100644
--- a/cppuhelper/source/implbase_ex.cxx
+++ b/cppuhelper/source/implbase_ex.cxx
@@ -64,6 +64,7 @@ static bool td_equals(
 static type_entry * getTypeEntries( class_data * cd )
 {
     type_entry * pEntries = cd->m_typeEntries;
+    if (! cd->m_storedTypeRefs) // not inited?
     {
         static std::mutex aMutex;
         std::scoped_lock guard( aMutex );
@@ -85,9 +86,14 @@ static type_entry * getTypeEntries( class_data * cd )
                 // ref is statically held by getCppuType()
                 pEntry->m_type.typeRef = rType.getTypeLibType();
             }
+            OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
             cd->m_storedTypeRefs = true;
         }
     }
+    else
+    {
+        OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+    }
     return pEntries;
 }
 

Reply via email to