[Lldb-commits] [PATCH] D65152: Fix issues with inferior stdout coming out of order
Pavel Labath via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Jul 23 08:05:10 PDT 2019
labath created this revision.
labath added reviewers: clayborg, jingham.
Herald added a subscriber: jfb.
We've had a bug where two pieces of code, executing on two threads were
attempting to write inferior output simultaneously. The first one was in
Debugger::HandleProcessEvent, which handled the cases where stdout was
coming while the process was running. The second was in
CommandInterpreter::IOHandlerInputComplete, which was ensuring that any
output is printed before the command which caused process to run
terminates.
Both of these things make sense, but the fact they were implemented as
two independent functions without any synchronization meant that race
conditions could occur (e.g. both threads call process->GetSTDOUT, get
two chunks of data, but then end up calling stream->Write in opposite
order). This was most apparent in situations where a process quickly
writes a bunch of output and then exits (as all our register tests do).
This patch adds a mutex to ensure that stdout forwarding happens
atomically. It also refactors a code somewhat in order to reduce code
duplication.
https://reviews.llvm.org/D65152
Files:
include/lldb/Core/Debugger.h
include/lldb/Interpreter/CommandInterpreter.h
source/Core/Debugger.cpp
source/Interpreter/CommandInterpreter.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65152.211304.patch
Type: text/x-patch
Size: 5742 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190723/b7f9a03e/attachment-0001.bin>
More information about the lldb-commits
mailing list