From 39fbf9b5e5d7fbe1f478cf45bc70c0a26b298032 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 23 Apr 2025 10:43:20 -0700 Subject: [PATCH] [lldb-dap] Ensure we aquire the SB API lock while handling requests. Aquiring the lock for the target should help ensure consistency with other background operations, like the thread monitoring events that can trigger run commands from a different thread. --- lldb/tools/lldb-dap/Handler/RequestHandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp index 3520dc2c71a55..be9273963654a 100644 --- a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp @@ -14,6 +14,7 @@ #include "Protocol/ProtocolBase.h" #include "RunInTerminal.h" #include "llvm/Support/Error.h" +#include #if !defined(_WIN32) #include @@ -180,6 +181,9 @@ void BaseRequestHandler::Run(const Request &request) { return; } + lldb::SBMutex lock = dap.GetAPIMutex(); + std::lock_guard guard(lock); + // FIXME: After all the requests have migrated from LegacyRequestHandler > // RequestHandler<> we should be able to move this into // RequestHandler<>::operator().