<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Race condition in debugserver stdout processing during application exit."
   href="https://bugs.llvm.org/show_bug.cgi?id=45454">45454</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Race condition in debugserver stdout processing during application exit.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lldb
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>10.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>lldb-dev@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>uldis.kalninsh@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jdevlieghere@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>