-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb] Fix lock inversion between statusline mutex and output mutex #135956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) ChangesFix 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:
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
|
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 statusline. Extend the uncritical section so we can redraw the statusline there. The loop in Editline::GetCharacter should be unnecessary. It would only loop if we had a successful read with length zero, which shouldn't be possible or when we can't convert a partial UTF-8 character, in which case we bail out.
59e80e3
to
215f328
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
…lvm#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 statusline. Extend the uncritical section so we can redraw the statusline there. The loop in Editline::GetCharacter should be unnecessary. It would only loop if we had a successful read with length zero, which shouldn't be possible or when we can't convert a partial UTF-8 character, in which case we bail out. rdar://149251156 (cherry picked from commit 8311620)
…-5f99e0d4b9ea-83116209331a [🍒 swift/release/6.2] [lldb] Fix lock inversion between statusline mutex and output mutex (llvm#135956)
…lvm#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 statusline. Extend the uncritical section so we can redraw the statusline there. The loop in Editline::GetCharacter should be unnecessary. It would only loop if we had a successful read with length zero, which shouldn't be possible or when we can't convert a partial UTF-8 character, in which case we bail out. rdar://149251156
…lvm#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 statusline. Extend the uncritical section so we can redraw the statusline there. The loop in Editline::GetCharacter should be unnecessary. It would only loop if we had a successful read with length zero, which shouldn't be possible or when we can't convert a partial UTF-8 character, in which case we bail out. rdar://149251156
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
statusline.
Extend the uncritical section so we can redraw the statusline there.
The loop in Editline::GetCharacter should be unnecessary. It would only
loop if we had a successful read with length zero, which shouldn't be
possible or when we can't convert a partial UTF-8 character, in which
case we bail out.
rdar://149251156