https://github.com/pranavk created 
https://github.com/llvm/llvm-project/pull/217433

When adopting the TargetAPIMutex returned by exe_ctx.AllowResume(), using 
std::lock_guard with std::adopt_lock fails with -Werror=thread-safety-analysis 
on newer libc++ toolchains because lock_guard's adopt_lock constructor requires 
holding the capability at the call site. Switching to std::unique_lock matches 
the other TargetAPIMutex adoption call sites and provides correct RAII cleanup.

>From 3b6efb0345dd9ae9d341c0464664aa5c2ac6c4ab Mon Sep 17 00:00:00 2001
From: Pranav Kant <[email protected]>
Date: Wed, 19 Aug 2026 11:47:41 -0700
Subject: [PATCH] [lldb] Use std::unique_lock instead of std::lock_guard in
 ResumeNewPlan

When adopting the TargetAPIMutex returned by exe_ctx.AllowResume(),
using std::lock_guard with std::adopt_lock fails with
-Werror=thread-safety-analysis on newer libc++ toolchains because
lock_guard's adopt_lock constructor requires holding the capability
at the call site. Switching to std::unique_lock matches the other
TargetAPIMutex adoption call sites and provides correct RAII cleanup.

Assisted by: Gemini
---
 lldb/source/API/SBThread.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index 90cd0fe447540..c3c2e80af6913 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -465,7 +465,7 @@ static Status ResumeNewPlan(StoppedExecutionContext exe_ctx,
 
   // Release the run lock but keep the API lock.
   TargetAPIMutex api_mutex = exe_ctx.AllowResume();
-  std::lock_guard<TargetAPIMutex> guard(api_mutex, std::adopt_lock);
+  std::unique_lock<TargetAPIMutex> guard(api_mutex, std::adopt_lock);
   if (process->GetTarget().GetDebugger().GetAsyncExecution())
     return process->Resume();
   return process->ResumeSynchronous(nullptr);

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to