From 0df677f7ace7cd4a8e6dc7424351e71809737fc2 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 7 Jul 2021 10:33:28 +0200 Subject: [PATCH] AutoTest: Guard simultaneous access to header cache It is accessed from multiple threads at once. Guard with mutex to avoid crashes. Amends 64ce2a6f4374012b37b420dc0aaa6ea406bf7168 Change-Id: I5048e5fcdb27b2492656b302775378829b6da013 Reviewed-by: Christian Stenger --- src/plugins/autotest/itestparser.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/autotest/itestparser.cpp b/src/plugins/autotest/itestparser.cpp index fd021df42ef..b11393b9520 100644 --- a/src/plugins/autotest/itestparser.cpp +++ b/src/plugins/autotest/itestparser.cpp @@ -37,6 +37,7 @@ namespace Autotest { using LookupInfo = QPair; static QHash s_pchLookupCache; +Q_GLOBAL_STATIC(QMutex, s_cacheMutex); CppParser::CppParser(ITestFramework *framework) : ITestParser(framework) @@ -96,6 +97,7 @@ bool precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot, } return it.value(); }; + QMutexLocker l(s_cacheMutex()); return Utils::anyOf(precompiledHeaders, headerContains); } @@ -127,6 +129,7 @@ void CppParser::release() { m_cppSnapshot = CPlusPlus::Snapshot(); m_workingCopy = CppTools::WorkingCopy(); + QMutexLocker l(s_cacheMutex()); s_pchLookupCache.clear(); }