[Lldb-commits] [lldb] [lldb] Fix deadlock between statusline and output mutex (PR #135956)

via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 16 05:40:21 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

<details>
<summary>Changes</summary>

Fix a deadlock between the statusline mutex (in Debugger) and the output file mutex (in LockedStreamFile). The deadlock occurs when the main thread is calling the statusline callback while holding the output mutex in Editline, while the default event thread is trying to update the stausline.

rdar://149251156

---
Full diff: https://github.com/llvm/llvm-project/pull/135956.diff


1 Files Affected:

- (modified) lldb/source/Host/common/Editline.cpp (+4-1) 


``````````diff
diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp
index 29abaf7c65f28..6900da9909eb8 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -567,8 +567,11 @@ int Editline::GetCharacter(EditLineGetCharType *c) {
     m_needs_prompt_repaint = false;
   }
 
-  if (m_redraw_callback)
+  if (m_redraw_callback) {
+    m_locked_output.reset();
     m_redraw_callback();
+    m_locked_output.emplace(m_output_stream_sp->Lock());
+  }
 
   if (m_multiline_enabled) {
     // Detect when the number of rows used for this input line changes due to

``````````

</details>


https://github.com/llvm/llvm-project/pull/135956


More information about the lldb-commits mailing list