<div dir="ltr">I just noticed a couple tsan warning when using your patch in an interactive session. It's not obvious to me if these are real issues or not:<div><br></div><div><div>==================</div><div>WARNING: ThreadSanitizer: data race (pid=42951)</div><div> Write of size 1 at 0x7d44000046b0 by thread T6:</div><div> #0 lldb_private::IOHandler::SetIsDone(bool) ../tools/lldb/include/lldb/Core/IOHandler.h:95 (liblldb.so.3.7+0x0000019d0861)</div><div> #1 lldb_private::Process::PushProcessIOHandler() ../tools/lldb/source/Target/Process.cpp:5258 (liblldb.so.3.7+0x000001c1848c)</div><div> #2 lldb_private::Process::HandlePrivateEvent(std::shared_ptr<lldb_private::Event>&) ../tools/lldb/source/Target/Process.cpp:4432 (liblldb.so.3.7+0x000001c15421)</div><div> #3 lldb_private::Process::RunPrivateStateThread() ../tools/lldb/source/Target/Process.cpp:4573 (liblldb.so.3.7+0x000001c1875d)</div><div> #4 lldb_private::Process::PrivateStateThread(void*) ../tools/lldb/source/Target/Process.cpp:4496 (liblldb.so.3.7+0x000001c180e1)</div><div> #5 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) ../tools/lldb/source/Host/common/HostNativeThreadBase.cpp:86 (liblldb.so.3.7+0x0000019855e9)</div><div><br></div><div> Previous write of size 1 at 0x7d44000046b0 by main thread:</div><div> #0 lldb_private::IOHandler::SetIsDone(bool) ../tools/lldb/include/lldb/Core/IOHandler.h:95 (liblldb.so.3.7+0x0000019d0861)</div><div> #1 IOHandlerProcessSTDIO::Run() ../tools/lldb/source/Target/Process.cpp:5088 (liblldb.so.3.7+0x000001c292c7)</div><div> #2 lldb_private::Debugger::ExecuteIOHandlers() ../tools/lldb/source/Core/Debugger.cpp:901 (liblldb.so.3.7+0x0000019a6bcc)</div><div> #3 lldb_private::CommandInterpreter::RunCommandInterpreter(bool, bool, lldb_private::CommandInterpreterRunOptions&) ../tools/lldb/source/Interpreter/CommandInterpreter.cpp:3234 (liblldb.so.3.7+0x000001b0481f)</div><div> #4 lldb::SBDebugger::RunCommandInterpreter(bool, bool) ../tools/lldb/source/API/SBDebugger.cpp:980 (liblldb.so.3.7+0x000000be61fb)</div><div> #5 Driver::MainLoop() ../tools/lldb/tools/driver/Driver.cpp:1152 (lldb-3.7.0+0x0000000bd9d2)</div><div> #6 main ../tools/lldb/tools/driver/Driver.cpp:1252 (lldb-3.7.0+0x0000000bdfae)</div><div><br></div><div> Location is heap block of size 304 at 0x7d4400004600 allocated by main thread:</div><div> #0 operator new(unsigned long) <null>:0 (lldb-3.7.0+0x00000005459d)</div><div> #1 lldb_private::Process::SetSTDIOFileDescriptor(int) ../tools/lldb/source/Target/Process.cpp:5235 (liblldb.so.3.7+0x000001c19957)</div><div> #2 lldb_private::platform_linux::PlatformLinux::DebugProcess(lldb_private::ProcessLaunchInfo&, lldb_private::Debugger&, lldb_private::Target*, lldb_private::Error&) ../tools/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp:831 (liblldb.so.3.7+0x000001d94710)</div><div> #3 lldb_private::Target::Launch(lldb_private::ProcessLaunchInfo&, lldb_private::Stream*) ../tools/lldb/source/Target/Target.cpp:2602 (liblldb.so.3.7+0x000001c53197)</div><div> #4 CommandObjectProcessLaunch::DoExecute(lldb_private::Args&, lldb_private::CommandReturnObject&) ../tools/lldb/source/Commands/CommandObjectProcess.cpp:263 (liblldb.so.3.7+0x000001eb1b69)</div><div> #5 lldb_private::CommandObjectParsed::Execute(char const*, lldb_private::CommandReturnObject&) ../tools/lldb/source/Interpreter/CommandObject.cpp:1075 (liblldb.so.3.7+0x000001b0ef76)</div><div> #6 lldb_private::CommandInterpreter::HandleCommand(char const*, lldb_private::LazyBool, lldb_private::CommandReturnObject&, lldb_private::ExecutionContext*, bool, bool) ../tools/lldb/source/Interpreter/CommandInterpreter.cpp:1812 (liblldb.so.3.7+0x000001b00e4a)</div><div> #7 lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&, std::string&) ../tools/lldb/source/Interpreter/CommandInterpreter.cpp:2997 (liblldb.so.3.7+0x000001b03e5b)</div><div> #8 non-virtual thunk to lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&, std::string&) ../tools/lldb/source/Interpreter/CommandInterpreter.cpp:3076 (liblldb.so.3.7+0x000001b04230)</div><div> #9 lldb_private::IOHandlerEditline::Run() ../tools/lldb/source/Core/IOHandler.cpp:740 (liblldb.so.3.7+0x0000019cac7c)</div><div> #10 lldb_private::Debugger::ExecuteIOHandlers() ../tools/lldb/source/Core/Debugger.cpp:901 (liblldb.so.3.7+0x0000019a6bcc)</div><div> #11 lldb_private::CommandInterpreter::RunCommandInterpreter(bool, bool, lldb_private::CommandInterpreterRunOptions&) ../tools/lldb/source/Interpreter/CommandInterpreter.cpp:3234 (liblldb.so.3.7+0x000001b0481f)</div><div> #12 lldb::SBDebugger::RunCommandInterpreter(bool, bool) ../tools/lldb/source/API/SBDebugger.cpp:980 (liblldb.so.3.7+0x000000be61fb)</div><div> #13 Driver::MainLoop() ../tools/lldb/tools/driver/Driver.cpp:1152 (lldb-3.7.0+0x0000000bd9d2)</div><div> #14 main ../tools/lldb/tools/driver/Driver.cpp:1252 (lldb-3.7.0+0x0000000bdfae)</div><div><br></div><div> Thread T6 'intern-state' (tid=42969, running) created by main thread at:</div><div> #0 pthread_create <null>:0 (lldb-3.7.0+0x0000000578a1)</div><div> #1 lldb_private::ThreadLauncher::LaunchThread(llvm::StringRef, void* (*)(void*), void*, lldb_private::Error*, unsigned long) ../tools/lldb/source/Host/common/ThreadLauncher.cpp:71 (liblldb.so.3.7+0x00000197ab14)</div><div> #2 lldb_private::Process::StartPrivateStateThread(bool) ../tools/lldb/source/Target/Process.cpp:4266 (liblldb.so.3.7+0x000001c15cb3)</div><div> #3 lldb_private::Process::Launch(lldb_private::ProcessLaunchInfo&) ../tools/lldb/source/Target/Process.cpp:3182 (liblldb.so.3.7+0x000001c15a48)</div><div> #4 lldb_private::platform_linux::PlatformLinux::DebugProcess(lldb_private::ProcessLaunchInfo&, lldb_private::Debugger&, lldb_private::Target*, lldb_private::Error&) ../tools/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp:805 (liblldb.so.3.7+0x000001d943bb)</div><div> #5 lldb_private::Target::Launch(lldb_private::ProcessLaunchInfo&, lldb_private::Stream*) ../tools/lldb/source/Target/Target.cpp:2602 (liblldb.so.3.7+0x000001c53197)</div><div> #6 CommandObjectProcessLaunch::DoExecute(lldb_private::Args&, lldb_private::CommandReturnObject&) ../tools/lldb/source/Commands/CommandObjectProcess.cpp:263 (liblldb.so.3.7+0x000001eb1b69)</div><div> #7 lldb_private::CommandObjectParsed::Execute(char const*, lldb_private::CommandReturnObject&) ../tools/lldb/source/Interpreter/CommandObject.cpp:1075 (liblldb.so.3.7+0x000001b0ef76)</div><div> #8 lldb_private::CommandInterpreter::HandleCommand(char const*, lldb_private::LazyBool, lldb_private::CommandReturnObject&, lldb_private::ExecutionContext*, bool, bool) ../tools/lldb/source/Interpreter/CommandInterpreter.cpp:1812 (liblldb.so.3.7+0x000001b00e4a)</div><div> #9 lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&, std::string&) ../tools/lldb/source/Interpreter/CommandInterpreter.cpp:2997 (liblldb.so.3.7+0x000001b03e5b)</div><div> #10 non-virtual thunk to lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&, std::string&) ../tools/lldb/source/Interpreter/CommandInterpreter.cpp:3076 (liblldb.so.3.7+0x000001b04230)</div><div> #11 lldb_private::IOHandlerEditline::Run() ../tools/lldb/source/Core/IOHandler.cpp:740 (liblldb.so.3.7+0x0000019cac7c)</div><div> #12 lldb_private::Debugger::ExecuteIOHandlers() ../tools/lldb/source/Core/Debugger.cpp:901 (liblldb.so.3.7+0x0000019a6bcc)</div><div> #13 lldb_private::CommandInterpreter::RunCommandInterpreter(bool, bool, lldb_private::CommandInterpreterRunOptions&) ../tools/lldb/source/Interpreter/CommandInterpreter.cpp:3234 (liblldb.so.3.7+0x000001b0481f)</div><div> #14 lldb::SBDebugger::RunCommandInterpreter(bool, bool) ../tools/lldb/source/API/SBDebugger.cpp:980 (liblldb.so.3.7+0x000000be61fb)</div><div> #15 Driver::MainLoop() ../tools/lldb/tools/driver/Driver.cpp:1152 (lldb-3.7.0+0x0000000bd9d2)</div><div> #16 main ../tools/lldb/tools/driver/Driver.cpp:1252 (lldb-3.7.0+0x0000000bdfae)</div><div><br></div><div>SUMMARY: ThreadSanitizer: data race ../tools/lldb/include/lldb/Core/IOHandler.h:95 lldb_private::IOHandler::SetIsDone(bool)</div><div>==================</div><div>Process 42968 stopped</div><div>* thread #1: tid = 42968, 0x00007ffff81db89a helloserver`main.main + 26 at helloserver.go:26, name = 'helloserver', stop reason = breakpoint 1.1</div><div> frame #0: 0x00007ffff81db89a helloserver`main.main + 26 at helloserver.go:26</div><div>==================</div><div>WARNING: ThreadSanitizer: data race (pid=42951)</div><div> Read of size 8 at 0x7da0000080c0 by thread T2 (mutexes: write M171):</div><div> #0 write <null>:0 (lldb-3.7.0+0x0000000649c0)</div><div> #1 operator() ../tools/lldb/source/Host/posix/PipePosix.cpp:416 (liblldb.so.3.7+0x000001982201)</div><div> #2 std::_Function_handler<lldb_private::Error (bool&), lldb_private::PipePosix::Write(void const*, unsigned long, unsigned long&)::$_1>::_M_invoke(std::_Any_data const&, bool&) /usr/include/c++/4.8/functional:2056 (liblldb.so.3.7+0x000001981f9c)</div><div> #3 std::function<lldb_private::Error (bool&)>::operator()(bool&) const /usr/include/c++/4.8/functional:2464 (liblldb.so.3.7+0x000001983329)</div><div> #4 (anonymous namespace)::SelectIO(int, bool, std::function<lldb_private::Error (bool&)> const&, std::chrono::duration<long, std::ratio<1l, 1000000l> > const&) ../tools/lldb/source/Host/posix/PipePosix.cpp:118 (liblldb.so.3.7+0x000001981c47)</div><div> #5 lldb_private::PipePosix::Write(void const*, unsigned long, unsigned long&) ../tools/lldb/source/Host/posix/PipePosix.cpp:411 (liblldb.so.3.7+0x000001981e43)</div><div> #6 IOHandlerProcessSTDIO::Cancel() ../tools/lldb/source/Target/Process.cpp:5167 (liblldb.so.3.7+0x000001c297da)</div><div> #7 lldb_private::Debugger::PopIOHandler(std::shared_ptr<lldb_private::IOHandler> const&) ../tools/lldb/source/Core/Debugger.cpp:1071 (liblldb.so.3.7+0x0000019a6add)</div><div> #8 lldb_private::Process::PopProcessIOHandler() ../tools/lldb/source/Target/Process.cpp:5270 (liblldb.so.3.7+0x000001c106f9)</div><div> #9 lldb_private::Debugger::HandleProcessEvent(std::shared_ptr<lldb_private::Event> const&) ../tools/lldb/source/Core/Debugger.cpp:1517 (liblldb.so.3.7+0x0000019a8303)</div><div> #10 lldb_private::Debugger::DefaultEventHandler() ../tools/lldb/source/Core/Debugger.cpp:1604 (liblldb.so.3.7+0x0000019a869e)</div><div> #11 lldb_private::Debugger::EventHandlerThread(void*) ../tools/lldb/source/Core/Debugger.cpp:1662 (liblldb.so.3.7+0x0000019a88c9)</div><div> #12 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) ../tools/lldb/source/Host/common/HostNativeThreadBase.cpp:86 (liblldb.so.3.7+0x0000019855e9)</div><div><br></div><div> Previous write of size 8 at 0x7da0000080c0 by main thread:</div><div> #0 pipe2 <null>:0 (lldb-3.7.0+0x00000005f6c0)</div><div> #1 lldb_private::PipePosix::CreateNew(bool) ../tools/lldb/source/Host/posix/PipePosix.cpp:168 (liblldb.so.3.7+0x000001980cc4)</div><div> #2 IOHandlerProcessSTDIO::OpenPipes() ../tools/lldb/source/Target/Process.cpp:5070 (liblldb.so.3.7+0x000001c2994b)</div><div> #3 IOHandlerProcessSTDIO::Run() ../tools/lldb/source/Target/Process.cpp:5089 (liblldb.so.3.7+0x000001c292cf)</div><div> #4 lldb_private::Debugger::ExecuteIOHandlers() ../tools/lldb/source/Core/Debugger.cpp:901 (liblldb.so.3.7+0x0000019a6bcc)</div><div> #5 lldb_private::CommandInterpreter::RunCommandInterpreter(bool, bool, lldb_private::CommandInterpreterRunOptions&) ../tools/lldb/source/Interpreter/CommandInterpreter.cpp:3234 (liblldb.so.3.7+0x000001b0481f)</div><div> #6 lldb::SBDebugger::RunCommandInterpreter(bool, bool) ../tools/lldb/source/API/SBDebugger.cpp:980 (liblldb.so.3.7+0x000000be61fb)</div><div> #7 Driver::MainLoop() ../tools/lldb/tools/driver/Driver.cpp:1152 (lldb-3.7.0+0x0000000bd9d2)</div><div> #8 main ../tools/lldb/tools/driver/Driver.cpp:1252 (lldb-3.7.0+0x0000000bdfae)</div><div><br></div><div> Location is file descriptor 12 created by main thread at:</div><div> #0 pipe2 <null>:0 (lldb-3.7.0+0x00000005f6c0)</div><div> #1 lldb_private::PipePosix::CreateNew(bool) ../tools/lldb/source/Host/posix/PipePosix.cpp:168 (liblldb.so.3.7+0x000001980cc4)</div><div> #2 IOHandlerProcessSTDIO::OpenPipes() ../tools/lldb/source/Target/Process.cpp:5070 (liblldb.so.3.7+0x000001c2994b)</div><div> #3 IOHandlerProcessSTDIO::Run() ../tools/lldb/source/Target/Process.cpp:5089 (liblldb.so.3.7+0x000001c292cf)</div><div> #4 lldb_private::Debugger::ExecuteIOHandlers() ../tools/lldb/source/Core/Debugger.cpp:901 (liblldb.so.3.7+0x0000019a6bcc)</div><div> #5 lldb_private::CommandInterpreter::RunCommandInterpreter(bool, bool, lldb_private::CommandInterpreterRunOptions&) ../tools/lldb/source/Interpreter/CommandInterpreter.cpp:3234 (liblldb.so.3.7+0x000001b0481f)</div><div> #6 lldb::SBDebugger::RunCommandInterpreter(bool, bool) ../tools/lldb/source/API/SBDebugger.cpp:980 (liblldb.so.3.7+0x000000be61fb)</div><div> #7 Driver::MainLoop() ../tools/lldb/tools/driver/Driver.cpp:1152 (lldb-3.7.0+0x0000000bd9d2)</div><div> #8 main ../tools/lldb/tools/driver/Driver.cpp:1252 (lldb-3.7.0+0x0000000bdfae)</div><div><br></div><div> Mutex M171 (0x7d680001cbc8) created at:</div><div> #0 pthread_mutex_init <null>:0 (lldb-3.7.0+0x000000058cb0)</div><div> #1 Mutex ../tools/lldb/source/Host/common/Mutex.cpp:237 (liblldb.so.3.7+0x000001977f1a)</div><div> #2 IOHandlerStack ../tools/lldb/include/lldb/Core/IOHandler.h:716 (liblldb.so.3.7+0x0000019a97d7)</div><div> #3 Debugger ../tools/lldb/source/Core/Debugger.cpp:670 (liblldb.so.3.7+0x0000019a5bf4)</div><div> #4 lldb_private::Debugger::CreateInstance(void (*)(char const*, void*), void*) ../tools/lldb/source/Core/Debugger.cpp:557 (liblldb.so.3.7+0x0000019a52cb)</div><div> #5 lldb::SBDebugger::Create(bool, void (*)(char const*, void*), void*) ../tools/lldb/source/API/SBDebugger.cpp:177 (liblldb.so.3.7+0x000000be3f37)</div><div> #6 lldb::SBDebugger::Create(bool) ../tools/lldb/source/API/SBDebugger.cpp:158 (liblldb.so.3.7+0x000000be4085)</div><div> #7 Driver ../tools/lldb/tools/driver/Driver.cpp:142 (lldb-3.7.0+0x0000000bb369)</div><div> #8 main ../tools/lldb/tools/driver/Driver.cpp:1240 (lldb-3.7.0+0x0000000bdf05)</div><div><br></div><div> Thread T2 'event-handler' (tid=42957, running) created by main thread at:</div><div> #0 pthread_create <null>:0 (lldb-3.7.0+0x0000000578a1)</div><div> #1 lldb_private::ThreadLauncher::LaunchThread(llvm::StringRef, void* (*)(void*), void*, lldb_private::Error*, unsigned long) ../tools/lldb/source/Host/common/ThreadLauncher.cpp:71 (liblldb.so.3.7+0x00000197ab87)</div><div> #2 lldb_private::Debugger::StartEventHandlerThread() ../tools/lldb/source/Core/Debugger.cpp:1679 (liblldb.so.3.7+0x0000019a899e)</div><div> #3 lldb_private::CommandInterpreter::RunCommandInterpreter(bool, bool, lldb_private::CommandInterpreterRunOptions&) ../tools/lldb/source/Interpreter/CommandInterpreter.cpp:3226 (liblldb.so.3.7+0x000001b04800)</div><div> #4 lldb::SBDebugger::RunCommandInterpreter(bool, bool) ../tools/lldb/source/API/SBDebugger.cpp:980 (liblldb.so.3.7+0x000000be61fb)</div><div> #5 Driver::MainLoop() ../tools/lldb/tools/driver/Driver.cpp:1152 (lldb-3.7.0+0x0000000bd9d2)</div><div> #6 main ../tools/lldb/tools/driver/Driver.cpp:1252 (lldb-3.7.0+0x0000000bdfae)</div><div><br></div><div>SUMMARY: ThreadSanitizer: data race ??:0 write</div><div>==================</div></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature">-- Ryan Brown<br></div></div>
<br><div class="gmail_quote">On Mon, May 18, 2015 at 6:22 AM, Pavel Labath <span dir="ltr"><<a href="mailto:labath@google.com" target="_blank">labath@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">BTW, the patch I mention is here <<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D9823&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=DDUMf06MYELAe1Nlv7KChiwJLLHbYha4jtK_AOiWqwQ&m=_ne1yYOCyrQJrq87e7QjHLKPsMn1eiTRSgAWkbGrerw&s=BjEIrTXForx75eA08m9hHO09RPXrRO3GhK1xQgzIm7o&e=" target="_blank">http://reviews.llvm.org/D9823</a>>.<br>
<div class="HOEnZb"><div class="h5"><br>
On 18 May 2015 at 13:29, Pavel Labath <<a href="mailto:labath@google.com">labath@google.com</a>> wrote:<br>
> Hello everyone,<br>
><br>
> I have made a new patch to attempt to solve this issue. It is<br>
> basically a combination of two of the approaches posted here by Greg:<br>
> fix SyncIOHandler so it doesn't hang and pipe all asynchronous output<br>
> through the current IOHandler. I have added some synchronization there<br>
> to avoid some of the races I have found. Could you please test it<br>
> again and see if it works for you.<br>
><br>
> regards,<br>
> pl<br>
_______________________________________________<br>
lldb-dev mailing list<br>
<a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
</div></div></blockquote></div><br></div>