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

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

>From 59e80e36a07922684dba14f421bca3176a6b5a13 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jo...@devlieghere.com>
Date: Wed, 16 Apr 2025 14:29:27 +0200
Subject: [PATCH] [lldb] Fix deadlock between statusline and output mutex

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
---
 lldb/source/Host/common/Editline.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to