Fixes the occasional crash on exit when quitting lldb with control-D.
If the IOChannel has already freed out its m_driver member, and
there's still a character to be read/written (that is, the ^D
character), just skip that char instead of trying to write through
a null object pointer.
llvm-svn: 137421
diff --git a/lldb/tools/driver/IOChannel.cpp b/lldb/tools/driver/IOChannel.cpp
index 6f776c9..b64c8f5 100644
--- a/lldb/tools/driver/IOChannel.cpp
+++ b/lldb/tools/driver/IOChannel.cpp
@@ -503,6 +503,15 @@
if (len == 0)
return;
+ // We're in the process of exiting -- IOChannel::Run() has already completed
+ // and set m_driver to NULL - it is time for us to leave now. We might not
+ // print the final ^D to stdout in this case. We need to do some re-work on
+ // how the I/O streams are managed at some point.
+ if (m_driver == NULL)
+ {
+ return;
+ }
+
// Use the mutex to make sure OutWrite and ErrWrite do not interfere with each other's output.
IOLocker locker (m_output_mutex);
if (m_driver->EditlineReaderIsTop() && asynchronous)