[lldb-dev] Patch for garbage characters on quit

Mike Sartain mikesart at valvesoftware.com
Tue May 21 14:58:00 PDT 2013


Just pinging on this one to see if it's ok?

Thanks much.

________________________________
From: lldb-dev-bounces at cs.uiuc.edu [lldb-dev-bounces at cs.uiuc.edu] on behalf of Matthew Sorrels [sorrels.m at gmail.com]
Sent: Friday, May 17, 2013 2:39 PM
To: lldb-dev at cs.uiuc.edu
Subject: [lldb-dev] Patch for garbage characters on quit

It's possible others aren't seeing this but on Ubuntu 12.04 64 bits, when I exit lldb I get a few randomish garbage characters spewed to the terminal.  It appears the problem is the shutdown of master_out_comm in tools/driver/Driver.cpp around line 1591.  But I'm not sure I know enough about how this works to say what I'm doing to fix it is the best solution.  Other code for handling a Communication clear appears to shut them down by doing the following:

    SetReadThreadBytesReceivedCallback (NULL, NULL);
    Disconnect (NULL);
    StopReadThread (NULL);

Using this sequence on the master_out_comm seems to stop it from spewing random characters while quiting.  Just stoping the read thread wasn't a good solution, since it caused a huge pause.  Had to set the callback to NULL and disconnect first.

It also seemed kind of odd to me that you are closing the editline_output_pty before shutting down master_out_comm and out_comm_2 (which both were passed the editline file descriptor).  So I moved that CloseMasterFileDescriptor down after shutting down master_out_comm and out_comm_2.  Not sure this really needed to be done(didn't make any visible difference), but it felt right.

Here's the patch -- it seems to work for me (but I have no Mac to test it on), it's very possible I'm completely misunderstanding how this should work.  I'm still trying to get my feet wet on this code base.  Thanks,



Index: tools/driver/Driver.cpp
===================================================================
--- tools/driver/Driver.cpp    (revision 182137)
+++ tools/driver/Driver.cpp    (working copy)
@@ -1587,9 +1587,16 @@
                 }
             }

-            editline_output_pty.CloseMasterFileDescriptor();
+
+            master_out_comm.SetReadThreadBytesReceivedCallback(NULL, NULL);
             master_out_comm.Disconnect();
+            master_out_comm.ReadThreadStop();
+
+            out_comm_2.SetReadThreadBytesReceivedCallback(NULL, NULL);
             out_comm_2.Disconnect();
+            out_comm_2.ReadThreadStop();
+
+            editline_output_pty.CloseMasterFileDescriptor();
             reset_stdin_termios();
             fclose (stdin);


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20130521/6bf4a991/attachment.html>


More information about the lldb-dev mailing list