[lldb-dev] [Bug 45454] New: Race condition in debugserver stdout processing during application exit.

via lldb-dev lldb-dev at lists.llvm.org
Tue Apr 7 01:10:53 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45454

            Bug ID: 45454
           Summary: Race condition in debugserver stdout processing during
                    application exit.
           Product: lldb
           Version: 10.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: uldis.kalninsh at gmail.com
                CC: jdevlieghere at apple.com, llvm-bugs at lists.llvm.org

There is a race condition in debugserver where application state processing
thread sends event_proc_state_changed before all the STDOUT is posted to
internal buffers.

Explanation:

Debugserver processes STDOUT in separate thread that runs select on the socket
attached to debugged process STDOUT/STDERR. This thread reads the socket
contents and posts them to internal STDOUT buffer and emits eBroadcastBitSTDOUT
event. When application finishes, the sockets receive EOF and the thread exits.

When debugged application exits, the process state thread flushes any output
available in internal STDOUT buffer and emits "event_proc_state_changed" event,
which is picked up by main event processing loop and sent to lldb as the last
message.

If State processing thread gets to the STDOUT buffer before STDOUT processing
thread can update the buffer, the last output from application is lost.

The state processing thread probably needs to join the STDOUT thread before
checking if any last STDOUT is left in there. Seems that in some way, this is
already done for profiling data thread.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20200407/d6964dd3/attachment.html>


More information about the lldb-dev mailing list