@@ -48,11 +48,16 @@ Status TargetList::CreateTarget(Debugger &debugger,
4848 LoadDependentFiles load_dependent_files,
4949 const OptionGroupPlatform *platform_options,
5050 TargetSP &target_sp) {
51- std::lock_guard<std::recursive_mutex> guard (m_target_list_mutex);
51+ // Create Target Internal does not modify any state
52+ // directly and instead calls into methods which
53+ // themselves are thread-safe. We need to do this so
54+ // the locate module call back doesn't cause a re-entry
55+ // dead lock when creating the target.
5256 auto result = TargetList::CreateTargetInternal (
5357 debugger, user_exe_path, triple_str, load_dependent_files,
5458 platform_options, target_sp);
5559
60+ std::lock_guard<std::recursive_mutex> guard (m_target_list_mutex);
5661 if (target_sp && result.Success ())
5762 AddTargetInternal (target_sp, /* do_select*/ true );
5863 return result;
@@ -63,11 +68,16 @@ Status TargetList::CreateTarget(Debugger &debugger,
6368 const ArchSpec &specified_arch,
6469 LoadDependentFiles load_dependent_files,
6570 PlatformSP &platform_sp, TargetSP &target_sp) {
66- std::lock_guard<std::recursive_mutex> guard (m_target_list_mutex);
71+ // Create Target Internal does not modify any state
72+ // directly and instead calls into methods which
73+ // themselves are thread-safe. We need to do this so
74+ // the locate module call back doesn't cause a re-entry
75+ // dead lock when creating the target.
6776 auto result = TargetList::CreateTargetInternal (
6877 debugger, user_exe_path, specified_arch, load_dependent_files,
6978 platform_sp, target_sp);
7079
80+ std::lock_guard<std::recursive_mutex> guard (m_target_list_mutex);
7181 if (target_sp && result.Success ())
7282 AddTargetInternal (target_sp, /* do_select*/ true );
7383 return result;
0 commit comments