Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lldb/tools/lldb-dap/DAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "lldb/API/SBEvent.h"
#include "lldb/API/SBLanguageRuntime.h"
#include "lldb/API/SBListener.h"
#include "lldb/API/SBMutex.h"
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBStream.h"
#include "lldb/Host/JSONTransport.h"
Expand Down Expand Up @@ -1452,7 +1453,11 @@ 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 to prevent deadlock when
// handling `modules_request`, which also requires both locks.
lldb::SBMutex api_mutex = GetAPIMutex();
const std::scoped_lock<lldb::SBMutex, std::mutex> guard(
api_mutex, modules_mutex);
for (uint32_t i = 0; i < num_modules; ++i) {
lldb::SBModule module =
lldb::SBTarget::GetModuleAtIndexFromEvent(i, event);
Expand Down
Loading