summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2023-12-28 21:57:57 +0000
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-12-29 12:51:31 +0100
commitd7bbd8363e3a6856fb7039050b45a5ea0a626f29 (patch)
tree8187066d63adca17e6acfe15e561c717e50a5690 /comphelper
parent06fe555abb0a482ecf2b2b94e6a8a4dcb26649ce (diff)
trace events: fix deadlock from non-recursive mutex.
Release lock over s_pBufferFullCallback: #4 std::lock_guard<std::mutex>::lock_guard(std::mutex&) #5 comphelper::TraceEvent::getEventVectorAndClear() #6 0x00007f2367c61836 in comphelper::TraceEvent::getRecordingAndClear() #7 0x00007f236877263e in (anonymous namespace)::TraceEventDumper::flushRecordings() #8 0x00007f2367c60cb7 in comphelper::TraceEvent::addRecording(rtl::OUString const&) regression from: commit c2424341ed444647d979a69ae55268e96fad3d56 Date: Sun Jan 30 10:30:27 2022 +0100 comphelper : use std::mutex in traceevent Change-Id: Ic89d63d14f06d710937a4da759976ae308c9df45 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161329 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/traceevent.cxx13
1 files changed, 7 insertions, 6 deletions
diff --git a/comphelper/source/misc/traceevent.cxx b/comphelper/source/misc/traceevent.cxx
index fb07e1caa771..1296404ebd32 100644
--- a/comphelper/source/misc/traceevent.cxx
+++ b/comphelper/source/misc/traceevent.cxx
@@ -40,15 +40,16 @@ std::mutex g_aMutex;
void TraceEvent::addRecording(const OUString& sObject)
{
- std::lock_guard aGuard(g_aMutex);
+ bool bEmitCallback;
+ {
+ std::lock_guard aGuard(g_aMutex);
- g_aRecording.emplace_back(sObject);
+ g_aRecording.emplace_back(sObject);
- if (s_nBufferSize > 0 && g_aRecording.size() >= s_nBufferSize)
- {
- if (s_pBufferFullCallback != nullptr)
- (*s_pBufferFullCallback)();
+ bEmitCallback = s_nBufferSize > 0 && g_aRecording.size() >= s_nBufferSize;
}
+ if (bEmitCallback && s_pBufferFullCallback != nullptr)
+ (*s_pBufferFullCallback)();
}
void TraceEvent::addInstantEvent(const char* sName, const std::map<OUString, OUString>& args)