[Lldb-commits] [lldb] [lldb] Use std::unique_lock instead of std::lock_guard in ResumeNewPlan (PR #217433)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 19 11:58:45 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Pranav Kant (pranavk)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/217433.diff
1 Files Affected:
- (modified) lldb/source/API/SBThread.cpp (+1-1)
``````````diff
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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/217433
More information about the lldb-commits
mailing list