This is an archive of the discontinued LLVM Phabricator instance.

[debugserver] wait for STDIO thread to finish before flushing output
Needs ReviewPublic

Authored by ukalnins on Jun 15 2020, 4:55 AM.

Details

Reviewers
jasonmolenda
Summary

When process, that debugserver is attached to, exits, there is a race condition
if the process STDIO will be consumed and appened to internal stdio buffer before
debugserver flushes the stdio buffer for the last time and sends process exit status to lldb.

This patch adds the ability to signal the stdio thread to stop and wait for it to finish and
uses this to wait for the thread to finish before flushing output for the last time.

This is a potential patch for https://bugs.llvm.org/show_bug.cgi?id=45454

To reliably reproduce the problem I added usleep(1000) in MachProcess::STDIOThread before calls to AppendSTDOUT.

Diff Detail

Event Timeline

ukalnins created this revision.Jun 15 2020, 4:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2020, 4:55 AM
ukalnins updated this revision to Diff 270732.Jun 15 2020, 6:22 AM

Fixed merge conflict.