Author: Raphael Isemann Date: 2021-05-24T19:49:57+02:00 New Revision: ba51da820e4dc73153009f8a621ef49711294ae1
URL: https://github.com/llvm/llvm-project/commit/ba51da820e4dc73153009f8a621ef49711294ae1 DIFF: https://github.com/llvm/llvm-project/commit/ba51da820e4dc73153009f8a621ef49711294ae1.diff LOG: [lldb] Add missing mutex guards to TargetList::CreateTarget TestMultipleTargets is randomly failing on the bots. The reason for that is that the test is calling `SBDebugger::CreateTarget` from multiple threads. `TargetList::CreateTarget` is curiously missing the guard that all of its other member functions have, so all the threads in the test end up changing the internal TargetList state at the same time and end up corrupting it. Reviewed By: vsk, JDevlieghere Differential Revision: https://reviews.llvm.org/D103020 Added: Modified: lldb/source/Target/TargetList.cpp Removed: ################################################################################ diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp index 1e5856dd0b221..595799cfc92aa 100644 --- a/lldb/source/Target/TargetList.cpp +++ b/lldb/source/Target/TargetList.cpp @@ -48,6 +48,7 @@ Status TargetList::CreateTarget(Debugger &debugger, LoadDependentFiles load_dependent_files, const OptionGroupPlatform *platform_options, TargetSP &target_sp) { + std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex); auto result = TargetList::CreateTargetInternal( debugger, user_exe_path, triple_str, load_dependent_files, platform_options, target_sp); @@ -62,6 +63,7 @@ Status TargetList::CreateTarget(Debugger &debugger, const ArchSpec &specified_arch, LoadDependentFiles load_dependent_files, PlatformSP &platform_sp, TargetSP &target_sp) { + std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex); auto result = TargetList::CreateTargetInternal( debugger, user_exe_path, specified_arch, load_dependent_files, platform_sp, target_sp); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits