comphelper/source/misc/traceevent.cxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
New commits: commit c10756b90dd8ed32fa4f370700870e00d93efdb4 Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Thu Dec 28 21:57:57 2023 +0000 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jan 2 14:12:45 2024 +0100 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.gran...@collabora.co.uk> (cherry picked from commit d7bbd8363e3a6856fb7039050b45a5ea0a626f29) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161551 Reviewed-by: Michael Meeks <michael.me...@collabora.com> 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)