[Lldb-commits] [PATCH] D48463: Prevent dead locking when calling PrintAsync
Raphael Isemann via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Jun 22 10:19:27 PDT 2018
teemperor added a reviewer: labath.
teemperor added a subscriber: labath.
teemperor added a comment.
Adding Pavel because he wrote the PrintAsync code.
Also @labath: Can you tell me what variables/functionality the `m_output_mutex` in Editline.cpp is supposed to shield? I don't see any documentation for that.
The `m_output_mutex` name suggests its related to console output, but we actually take the lock also when reading *input*. Especially in `EditLine::GetLine` we take a guard on the lock but then somehow unlock the guarded mutex from inside `Editline::GetCharacter` that we call afterwards (which completely breaks this patch):
// This mutex is locked by our caller (GetLine). Unlock it while we read a
// character (blocking operation), so we do not hold the mutex
// indefinitely. This gives a chance for someone to interrupt us. After
// Read returns, immediately lock the mutex again and check if we were
// interrupted.
m_output_mutex.unlock();
int read_count = m_input_connection.Read(&ch, 1, llvm::None, status, NULL);
m_output_mutex.lock();
if (m_editor_status == EditorStatus::Interrupted) {
while (read_count > 0 && status == lldb::eConnectionStatusSuccess)
read_count = m_input_connection.Read(&ch, 1, llvm::None, status, NULL);
lldbassert(status == lldb::eConnectionStatusInterrupted);
return 0;
}
https://reviews.llvm.org/D48463
More information about the lldb-commits
mailing list