================
@@ -1437,7 +1437,12 @@ void DAP::EventThread() {
const bool remove_module =
event_mask & lldb::SBTarget::eBroadcastBitModulesUnloaded;
- std::lock_guard<std::mutex> guard(modules_mutex);
+ // NOTE: Both mutexes must be acquired (API mutex first, then modules
+ // mutex) to prevent deadlock when handling `modules_request`, which
+ // also requires both locks.
+ lldb::SBMutex api_mutex = GetAPIMutex();
+ std::lock_guard api_guard(api_mutex);
+ std::lock_guard modules_guard(modules_mutex);
----------------
da-viper wrote:
I wanted to use that but, locking two mutex with
[std::scoped_lock](https://en.cppreference.com/w/cpp/thread/scoped_lock.html)
requires the mutex to implement `Lockable` `try_lock` so we have to add it to
SBMutex public api. not sure if it is something we want to support.
https://github.com/llvm/llvm-project/pull/163821
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits