summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2025-02-17 19:49:39 +0000
committerCaolán McNamara <caolan.mcnamara@collabora.com>2025-02-17 22:10:38 +0100
commit7a283ee5540e42662b723ac08d3ea1a0e454045e (patch)
treec64b88a46ef2677c739069652709d269f2f68419
parent7ff861a1ead95d12ed6ab301093c4ee488f7155f (diff)
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.mcnamara@collabora.com> Tested-by: Jenkins
-rw-r--r--comphelper/source/misc/compbase.cxx6
-rw-r--r--cppuhelper/source/compbase.cxx6
-rw-r--r--cppuhelper/source/implbase_ex.cxx6
3 files changed, 18 insertions, 0 deletions
diff --git a/comphelper/source/misc/compbase.cxx b/comphelper/source/misc/compbase.cxx
index 02efae8b71c45..eafabb0139370 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 aca77677a0f4a..ed4909b711069 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 9d3e034127371..3f88feb97dd1f 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;
}