[lldb-dev] Process::SyncIOHandler(), everyone please try out the following patch
Pavel Labath
labath at google.com
Fri May 15 03:57:09 PDT 2015
Hi all,
I have identified a lot of IOHandler races by manual code inspection.
I have a mostly-working fix for this, but I am still polishing it, and
will send it for review shortly.
The reason I say only "mostly" working is that I am not sure how to
handle IOHandlerEditline::Cancel on windows. Specifically, the
behavior of the handler when libedit is disabled. Currently Cancel()
and Interrupt() correctly interrupt the handler, but only when libedit
is in use. When libedit is off the IOHandler does a simple blocking
fgets to read the command. This is a problem since we cannot interrupt
the handler when we push another handler on top of the IO stack. Now,
I could implement this to use select(), but this will not work work on
windows.
Zachary, do you have any idea how could the Cancel() functionality be
implemented on windows? For now, I think I implement things in a way
that the missing cancelation problem will not be extremely annoying,
but in general, we should find a way to deal with this in the future.
I think I remember seeing also other places that needed a select
replacement on windows.
cheers,
pl
On 15 May 2015 at 01:38, Zachary Turner <zturner at google.com> wrote:
> Great results! I'm especially interested in these IOHandler issues, since we
> know for sure there are problems here.
>
> When you say Python can't find tsan, can you elaborate? I'm not sure how
> tsan works or the process used to run lldb under tsan, but i bet it's
> something we can figure out with more information.
>
> Also, what os is this on?
>
> On Thu, May 14, 2015 at 5:01 PM Ryan Brown <ribrdb at google.com> wrote:
>>
>> I just built lldb with tsan. The tests don't seem to work because python
>> can't find tsan, but a quick debugging session found a few issues:
>>
>> WARNING: ThreadSanitizer: data race (pid=64299)
>> Write of size 1 at 0x7d4400004bb0 by thread T6:
>> #0 lldb_private::IOHandler::SetIsDone(bool)
>> tools/lldb/include/lldb/Core/IOHandler.h:107
>> #1 lldb_private::Process::PushProcessIOHandler()
>> tools/lldb/source/Target/Process.cpp:5279
>> #2
>> lldb_private::Process::HandlePrivateEvent(std::shared_ptr<lldb_private::Event>&)
>> tools/lldb/source/Target/Process.cpp:4443
>> #3 lldb_private::Process::RunPrivateStateThread()
>> tools/lldb/source/Target/Process.cpp:4581
>> #4 lldb_private::Process::PrivateStateThread(void*)
>> tools/lldb/source/Target/Process.cpp:4505
>> #5 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*)
>> tools/lldb/source/Host/common/HostNativeThreadBase.cpp:81
>>
>> Previous write of size 1 at 0x7d4400004bb0 by main thread:
>> #0 lldb_private::IOHandler::SetIsDone(bool)
>> tools/lldb/include/lldb/Core/IOHandler.h:107
>> #1 IOHandlerProcessSTDIO::Run()
>> tools/lldb/source/Target/Process.cpp:5096
>> #2 lldb_private::Debugger::ExecuteIOHandlers()
>> tools/lldb/source/Core/Debugger.cpp:907
>> #3 lldb_private::CommandInterpreter::RunCommandInterpreter(bool, bool,
>> lldb_private::CommandInterpreterRunOptions&)
>> tools/lldb/source/Interpreter/CommandInterpreter.cpp:3234
>> #4 lldb::SBDebugger::RunCommandInterpreter(bool, bool)
>> tools/lldb/source/API/SBDebugger.cpp:980
>> #5 Driver::MainLoop() tools/lldb/tools/driver/Driver.cpp:1152
>> #6 main tools/lldb/tools/driver/Driver.cpp:1252
>>
>> ==================
>> WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock)
>> (pid=64299)
>> Cycle in lock order graph: M31728 (0x7d1000019e58) => M564
>> (0x7d680001d0f8) => M31728
>>
>> Mutex M564 acquired here while holding mutex M31728 in main thread:
>> #3 Locker tools/lldb/source/Host/common/Mutex.cpp:114
>> #4
>> lldb_private::ModuleList::FindSymbolsWithNameAndType(lldb_private::ConstString
>> const&, lldb::SymbolType, lldb_private::SymbolContextList&, bool) const
>> tools/lldb/source/Core/ModuleList.cpp:565
>> #5 JITLoaderGDB::GetSymbolAddress(lldb_private::ModuleList&,
>> lldb_private::ConstString const&, lldb::SymbolType) const
>> tools/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp:432
>> #6 JITLoaderGDB::SetJITBreakpoint(lldb_private::ModuleList&)
>> tools/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp:109
>> #7 JITLoaderGDB::DidLaunch()
>> tools/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp:84
>> #8 lldb_private::JITLoaderList::DidLaunch()
>> tools/lldb/source/Target/JITLoaderList.cpp:60
>> #9 lldb_private::Process::Launch(lldb_private::ProcessLaunchInfo&)
>> tools/lldb/source/Target/Process.cpp:3177
>> #10
>> 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
>> #11 lldb_private::Target::Launch(lldb_private::ProcessLaunchInfo&,
>> lldb_private::Stream*) tools/lldb/source/Target/Target.cpp:2602
>> #12 CommandObjectProcessLaunch::DoExecute(lldb_private::Args&,
>> lldb_private::CommandReturnObject&)
>> tools/lldb/source/Commands/CommandObjectProcess.cpp:263
>> #13 lldb_private::CommandObjectParsed::Execute(char const*,
>> lldb_private::CommandReturnObject&)
>> tools/lldb/source/Interpreter/CommandObject.cpp:1075
>> #14 lldb_private::CommandInterpreter::HandleCommand(char const*,
>> lldb_private::LazyBool, lldb_private::CommandReturnObject&,
>> lldb_private::ExecutionContext*, bool, bool)
>> tools/lldb/source/Interpreter/CommandInterpreter.cpp:1812
>> #15
>> lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&,
>> std::string&) tools/lldb/source/Interpreter/CommandInterpreter.cpp:2997
>> #16 non-virtual thunk to
>> lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&,
>> std::string&) tools/lldb/source/Interpreter/CommandInterpreter.cpp:3076
>> #17 lldb_private::IOHandlerEditline::Run()
>> tools/lldb/source/Core/IOHandler.cpp:729
>> #18 lldb_private::Debugger::ExecuteIOHandlers()
>> tools/lldb/source/Core/Debugger.cpp:907
>> #19 lldb_private::CommandInterpreter::RunCommandInterpreter(bool,
>> bool, lldb_private::CommandInterpreterRunOptions&)
>> tools/lldb/source/Interpreter/CommandInterpreter.cpp:3234
>> #20 lldb::SBDebugger::RunCommandInterpreter(bool, bool)
>> tools/lldb/source/API/SBDebugger.cpp:980
>> #21 Driver::MainLoop() tools/lldb/tools/driver/Driver.cpp:1152
>> #22 main tools/lldb/tools/driver/Driver.cpp:1252
>>
>> Mutex M31728 previously acquired by the same thread here:
>> #3 Locker tools/lldb/source/Host/common/Mutex.cpp:114
>> #4 lldb_private::JITLoaderList::DidLaunch()
>> tools/lldb/source/Target/JITLoaderList.cpp:58
>> #5 lldb_private::Process::Launch(lldb_private::ProcessLaunchInfo&)
>> tools/lldb/source/Target/Process.cpp:3177
>> #6
>> 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
>> #7 lldb_private::Target::Launch(lldb_private::ProcessLaunchInfo&,
>> lldb_private::Stream*) tools/lldb/source/Target/Target.cpp:2602
>> #8 CommandObjectProcessLaunch::DoExecute(lldb_private::Args&,
>> lldb_private::CommandReturnObject&)
>> tools/lldb/source/Commands/CommandObjectProcess.cpp:263
>> #9 lldb_private::CommandObjectParsed::Execute(char const*,
>> lldb_private::CommandReturnObject&)
>> tools/lldb/source/Interpreter/CommandObject.cpp:1075
>> #10 lldb_private::CommandInterpreter::HandleCommand(char const*,
>> lldb_private::LazyBool, lldb_private::CommandReturnObject&,
>> lldb_private::ExecutionContext*, bool, bool)
>> tools/lldb/source/Interpreter/CommandInterpreter.cpp:1812
>> #11
>> lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&,
>> std::string&) tools/lldb/source/Interpreter/CommandInterpreter.cpp:2997
>> #12 non-virtual thunk to
>> lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&,
>> std::string&) tools/lldb/source/Interpreter/CommandInterpreter.cpp:3076
>> #13 lldb_private::IOHandlerEditline::Run()
>> tools/lldb/source/Core/IOHandler.cpp:729
>> #14 lldb_private::Debugger::ExecuteIOHandlers()
>> tools/lldb/source/Core/Debugger.cpp:907
>> #15 lldb_private::CommandInterpreter::RunCommandInterpreter(bool,
>> bool, lldb_private::CommandInterpreterRunOptions&)
>> tools/lldb/source/Interpreter/CommandInterpreter.cpp:3234
>> #16 lldb::SBDebugger::RunCommandInterpreter(bool, bool)
>> tools/lldb/source/API/SBDebugger.cpp:980
>> #17 Driver::MainLoop() tools/lldb/tools/driver/Driver.cpp:1152
>> #18 main tools/lldb/tools/driver/Driver.cpp:1252
>>
>> Mutex M31728 acquired here while holding mutex M564 in thread T6:
>> #3 Locker tools/lldb/source/Host/common/Mutex.cpp:114
>> #4
>> lldb_private::JITLoaderList::ModulesDidLoad(lldb_private::ModuleList&)
>> tools/lldb/source/Target/JITLoaderList.cpp:74
>> #5 lldb_private::Process::ModulesDidLoad(lldb_private::ModuleList&)
>> tools/lldb/source/Target/Process.cpp:6466
>> #6 lldb_private::Target::ModulesDidLoad(lldb_private::ModuleList&)
>> tools/lldb/source/Target/Target.cpp:1286
>> #7 lldb_private::Target::ModuleAdded(lldb_private::ModuleList const&,
>> std::shared_ptr<lldb_private::Module> const&)
>> tools/lldb/source/Target/Target.cpp:1254
>> #8 non-virtual thunk to
>> lldb_private::Target::ModuleAdded(lldb_private::ModuleList const&,
>> std::shared_ptr<lldb_private::Module> const&)
>> tools/lldb/source/Target/Target.cpp:1256
>> #9
>> lldb_private::ModuleList::AppendImpl(std::shared_ptr<lldb_private::Module>
>> const&, bool) tools/lldb/source/Core/ModuleList.cpp:111
>> #10
>> lldb_private::ModuleList::Append(std::shared_ptr<lldb_private::Module>
>> const&) tools/lldb/source/Core/ModuleList.cpp:118
>> #11 lldb_private::Target::GetSharedModule(lldb_private::ModuleSpec
>> const&, lldb_private::Error*) tools/lldb/source/Target/Target.cpp:1810
>> #12
>> lldb_private::DynamicLoader::LoadModuleAtAddress(lldb_private::FileSpec
>> const&, unsigned long, unsigned long)
>> tools/lldb/source/Core/DynamicLoader.cpp:185
>> #13 DynamicLoaderPOSIXDYLD::LoadAllCurrentModules()
>> tools/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp:530
>> #14 DynamicLoaderPOSIXDYLD::EntryBreakpointHit(void*,
>> lldb_private::StoppointCallbackContext*, unsigned long, unsigned long)
>> tools/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp:343
>> #15
>> lldb_private::BreakpointOptions::InvokeCallback(lldb_private::StoppointCallbackContext*,
>> unsigned long, unsigned long)
>> tools/lldb/source/Breakpoint/BreakpointOptions.cpp:147
>> #16
>> lldb_private::Breakpoint::InvokeCallback(lldb_private::StoppointCallbackContext*,
>> int) tools/lldb/source/Breakpoint/Breakpoint.cpp:345
>> #17
>> lldb_private::BreakpointLocation::InvokeCallback(lldb_private::StoppointCallbackContext*)
>> tools/lldb/source/Breakpoint/BreakpointLocation.cpp:222
>> #18
>> lldb_private::BreakpointLocation::ShouldStop(lldb_private::StoppointCallbackContext*)
>> tools/lldb/source/Breakpoint/BreakpointLocation.cpp:465
>> #19
>> lldb_private::BreakpointLocationCollection::ShouldStop(lldb_private::StoppointCallbackContext*)
>> tools/lldb/source/Breakpoint/BreakpointLocationCollection.cpp:144
>> #20
>> lldb_private::BreakpointSite::ShouldStop(lldb_private::StoppointCallbackContext*)
>> tools/lldb/source/Breakpoint/BreakpointSite.cpp:69
>> #21
>> lldb_private::StopInfoBreakpoint::ShouldStopSynchronous(lldb_private::Event*)
>> tools/lldb/source/Target/StopInfo.cpp:200
>> #22 lldb_private::Thread::ShouldStop(lldb_private::Event*)
>> tools/lldb/source/Target/Thread.cpp:845
>> #23 lldb_private::ThreadList::ShouldStop(lldb_private::Event*)
>> tools/lldb/source/Target/ThreadList.cpp:318
>> #24 lldb_private::Process::ShouldBroadcastEvent(lldb_private::Event*)
>> tools/lldb/source/Target/Process.cpp:4181
>> #25
>> lldb_private::Process::HandlePrivateEvent(std::shared_ptr<lldb_private::Event>&)
>> tools/lldb/source/Target/Process.cpp:4422
>> #26 lldb_private::Process::RunPrivateStateThread()
>> tools/lldb/source/Target/Process.cpp:4581
>> #27 lldb_private::Process::PrivateStateThread(void*)
>> tools/lldb/source/Target/Process.cpp:4505
>> #28 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*)
>> tools/lldb/source/Host/common/HostNativeThreadBase.cpp:81
>>
>> Mutex M564 previously acquired by the same thread here:
>> #3 Locker tools/lldb/source/Host/common/Mutex.cpp:114
>> #4
>> lldb_private::ModuleList::AppendImpl(std::shared_ptr<lldb_private::Module>
>> const&, bool) tools/lldb/source/Core/ModuleList.cpp:108
>> #5
>> lldb_private::ModuleList::Append(std::shared_ptr<lldb_private::Module>
>> const&) tools/lldb/source/Core/ModuleList.cpp:118
>> #6 lldb_private::Target::GetSharedModule(lldb_private::ModuleSpec
>> const&, lldb_private::Error*) tools/lldb/source/Target/Target.cpp:1810
>> #7
>> lldb_private::DynamicLoader::LoadModuleAtAddress(lldb_private::FileSpec
>> const&, unsigned long, unsigned long)
>> tools/lldb/source/Core/DynamicLoader.cpp:185
>> #8 DynamicLoaderPOSIXDYLD::LoadAllCurrentModules()
>> tools/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp:530
>> #9 DynamicLoaderPOSIXDYLD::EntryBreakpointHit(void*,
>> lldb_private::StoppointCallbackContext*, unsigned long, unsigned long)
>> tools/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp:343
>> #10
>> lldb_private::BreakpointOptions::InvokeCallback(lldb_private::StoppointCallbackContext*,
>> unsigned long, unsigned long)
>> tools/lldb/source/Breakpoint/BreakpointOptions.cpp:147
>> #11
>> lldb_private::Breakpoint::InvokeCallback(lldb_private::StoppointCallbackContext*,
>> int) tools/lldb/source/Breakpoint/Breakpoint.cpp:345
>> #12
>> lldb_private::BreakpointLocation::InvokeCallback(lldb_private::StoppointCallbackContext*)
>> tools/lldb/source/Breakpoint/BreakpointLocation.cpp:222
>> #13
>> lldb_private::BreakpointLocation::ShouldStop(lldb_private::StoppointCallbackContext*)
>> tools/lldb/source/Breakpoint/BreakpointLocation.cpp:465
>> #14
>> lldb_private::BreakpointLocationCollection::ShouldStop(lldb_private::StoppointCallbackContext*)
>> tools/lldb/source/Breakpoint/BreakpointLocationCollection.cpp:144
>> #15
>> lldb_private::BreakpointSite::ShouldStop(lldb_private::StoppointCallbackContext*)
>> tools/lldb/source/Breakpoint/BreakpointSite.cpp:69
>> #16
>> lldb_private::StopInfoBreakpoint::ShouldStopSynchronous(lldb_private::Event*)
>> tools/lldb/source/Target/StopInfo.cpp:200
>> #17 lldb_private::Thread::ShouldStop(lldb_private::Event*)
>> tools/lldb/source/Target/Thread.cpp:845
>> #18 lldb_private::ThreadList::ShouldStop(lldb_private::Event*)
>> tools/lldb/source/Target/ThreadList.cpp:318
>> #19 lldb_private::Process::ShouldBroadcastEvent(lldb_private::Event*)
>> tools/lldb/source/Target/Process.cpp:4181
>> #20
>> lldb_private::Process::HandlePrivateEvent(std::shared_ptr<lldb_private::Event>&)
>> tools/lldb/source/Target/Process.cpp:4422
>> #21 lldb_private::Process::RunPrivateStateThread()
>> tools/lldb/source/Target/Process.cpp:4581
>> #22 lldb_private::Process::PrivateStateThread(void*)
>> tools/lldb/source/Target/Process.cpp:4505
>> #23 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*)
>> tools/lldb/source/Host/common/HostNativeThreadBase.cpp:81
>>
>> ==================
>> WARNING: ThreadSanitizer: data race (pid=64299)
>> Write of size 1 at 0x7d4400004bb1 by thread T2 (mutexes: write M168):
>> #0 lldb_private::IOHandler::Deactivate()
>> tools/lldb/include/lldb/Core/IOHandler.h:131
>> #1
>> lldb_private::Debugger::PopIOHandler(std::shared_ptr<lldb_private::IOHandler>
>> const&) tools/lldb/source/Core/Debugger.cpp:1064
>> #2 lldb_private::Process::PopProcessIOHandler()
>> tools/lldb/source/Target/Process.cpp:5291
>> #3
>> lldb_private::Debugger::HandleProcessEvent(std::shared_ptr<lldb_private::Event>
>> const&) tools/lldb/source/Core/Debugger.cpp:1544
>> #4 lldb_private::Debugger::DefaultEventHandler()
>> tools/lldb/source/Core/Debugger.cpp:1634
>> #5 lldb_private::Debugger::EventHandlerThread(void*)
>> tools/lldb/source/Core/Debugger.cpp:1696
>> #6 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*)
>> tools/lldb/source/Host/common/HostNativeThreadBase.cpp:81
>>
>> Previous write of size 1 at 0x7d4400004bb1 by main thread:
>> #0 lldb_private::IOHandler::Activate()
>> tools/lldb/include/lldb/Core/IOHandler.h:125
>> #1 lldb_private::Debugger::ExecuteIOHandlers()
>> tools/lldb/source/Core/Debugger.cpp:906
>> #2 lldb_private::CommandInterpreter::RunCommandInterpreter(bool, bool,
>> lldb_private::CommandInterpreterRunOptions&)
>> tools/lldb/source/Interpreter/CommandInterpreter.cpp:3234
>> #3 lldb::SBDebugger::RunCommandInterpreter(bool, bool)
>> tools/lldb/source/API/SBDebugger.cpp:980
>> #4 Driver::MainLoop() tools/lldb/tools/driver/Driver.cpp:1152
>> #5 main tools/lldb/tools/driver/Driver.cpp:1252
>>
>> ==================
>> WARNING: ThreadSanitizer: data race (pid=64299)
>> Read of size 8 at 0x7da0000080c0 by thread T2 (mutexes: write M168):
>> #0 write <null>:0
>> #1 operator() tools/lldb/source/Host/posix/PipePosix.cpp:416
>> #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/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/functional:2056
>> #3 std::function<lldb_private::Error (bool&)>::operator()(bool&) const
>> /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/functional:2464
>> #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
>> #5 lldb_private::PipePosix::Write(void const*, unsigned long, unsigned
>> long&) tools/lldb/source/Host/posix/PipePosix.cpp:411
>> #6 IOHandlerProcessSTDIO::Cancel()
>> tools/lldb/source/Target/Process.cpp:5192
>> #7
>> lldb_private::Debugger::PopIOHandler(std::shared_ptr<lldb_private::IOHandler>
>> const&) tools/lldb/source/Core/Debugger.cpp:1065
>> #8 lldb_private::Process::PopProcessIOHandler()
>> tools/lldb/source/Target/Process.cpp:5291
>> #9
>> lldb_private::Debugger::HandleProcessEvent(std::shared_ptr<lldb_private::Event>
>> const&) tools/lldb/source/Core/Debugger.cpp:1544
>> #10 lldb_private::Debugger::DefaultEventHandler()
>> tools/lldb/source/Core/Debugger.cpp:1634
>> #11 lldb_private::Debugger::EventHandlerThread(void*)
>> tools/lldb/source/Core/Debugger.cpp:1696
>> #12 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*)
>> tools/lldb/source/Host/common/HostNativeThreadBase.cpp:81
>>
>> Previous write of size 8 at 0x7da0000080c0 by main thread:
>> #0 pipe2 <null>:0
>> #1 lldb_private::PipePosix::CreateNew(bool)
>> tools/lldb/source/Host/posix/PipePosix.cpp:168
>> #2 IOHandlerProcessSTDIO::OpenPipes()
>> tools/lldb/source/Target/Process.cpp:5078
>> #3 IOHandlerProcessSTDIO::Run()
>> tools/lldb/source/Target/Process.cpp:5097
>> #4 lldb_private::Debugger::ExecuteIOHandlers()
>> tools/lldb/source/Core/Debugger.cpp:907
>> #5 lldb_private::CommandInterpreter::RunCommandInterpreter(bool, bool,
>> lldb_private::CommandInterpreterRunOptions&)
>> tools/lldb/source/Interpreter/CommandInterpreter.cpp:3234
>> #6 lldb::SBDebugger::RunCommandInterpreter(bool, bool)
>> tools/lldb/source/API/SBDebugger.cpp:980
>> #7 Driver::MainLoop() tools/lldb/tools/driver/Driver.cpp:1152
>> #8 main tools/lldb/tools/driver/Driver.cpp:1252
>>
>> Location is file descriptor 12 created by main thread at:
>> #0 pipe2 <null>:0
>> #1 lldb_private::PipePosix::CreateNew(bool)
>> tools/lldb/source/Host/posix/PipePosix.cpp:168
>> #2 IOHandlerProcessSTDIO::OpenPipes()
>> tools/lldb/source/Target/Process.cpp:5078
>> #3 IOHandlerProcessSTDIO::Run()
>> tools/lldb/source/Target/Process.cpp:5097
>> #4 lldb_private::Debugger::ExecuteIOHandlers()
>> tools/lldb/source/Core/Debugger.cpp:907
>> #5 lldb_private::CommandInterpreter::RunCommandInterpreter(bool, bool,
>> lldb_private::CommandInterpreterRunOptions&)
>> tools/lldb/source/Interpreter/CommandInterpreter.cpp:3234
>> #6 lldb::SBDebugger::RunCommandInterpreter(bool, bool)
>> tools/lldb/source/API/SBDebugger.cpp:980
>> #7 Driver::MainLoop() tools/lldb/tools/driver/Driver.cpp:1152
>> #8 main tools/lldb/tools/driver/Driver.cpp:1252
>>
>> ==================
>> WARNING: ThreadSanitizer: data race (pid=64299)
>> Read of size 8 at 0x7d080001a5c8 by main thread:
>> #0 lldb_private::HostNativeThreadBase::GetSystemHandle() const
>> tools/lldb/source/Host/common/HostNativeThreadBase.cpp:35
>> #1 lldb_private::HostThread::EqualsThread(unsigned long) const
>> tools/lldb/source/Host/common/HostThread.cpp:77
>> #2 lldb_private::Process::GetRunLock()
>> tools/lldb/source/Target/Process.cpp:6373
>> #3
>> lldb_private::ExecutionContextRef::SetTargetPtr(lldb_private::Target*, bool)
>> tools/lldb/source/Target/ExecutionContext.cpp:723
>> #4
>> lldb_private::CommandInterpreter::UpdateExecutionContext(lldb_private::ExecutionContext*)
>> tools/lldb/source/Interpreter/CommandInterpreter.cpp:2940
>> #5 lldb_private::CommandInterpreter::HandleCommand(char const*,
>> lldb_private::LazyBool, lldb_private::CommandReturnObject&,
>> lldb_private::ExecutionContext*, bool, bool)
>> tools/lldb/source/Interpreter/CommandInterpreter.cpp:1668
>> #6
>> lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&,
>> std::string&) tools/lldb/source/Interpreter/CommandInterpreter.cpp:2997
>> #7 non-virtual thunk to
>> lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&,
>> std::string&) tools/lldb/source/Interpreter/CommandInterpreter.cpp:3076
>> #8 lldb_private::IOHandlerEditline::Run()
>> tools/lldb/source/Core/IOHandler.cpp:729
>> #9 lldb_private::Debugger::ExecuteIOHandlers()
>> tools/lldb/source/Core/Debugger.cpp:907
>> #10 lldb_private::CommandInterpreter::RunCommandInterpreter(bool,
>> bool, lldb_private::CommandInterpreterRunOptions&)
>> tools/lldb/source/Interpreter/CommandInterpreter.cpp:3234
>> #11 lldb::SBDebugger::RunCommandInterpreter(bool, bool)
>> tools/lldb/source/API/SBDebugger.cpp:980
>> #12 Driver::MainLoop() tools/lldb/tools/driver/Driver.cpp:1152
>> #13 main tools/lldb/tools/driver/Driver.cpp:1252
>>
>> Previous write of size 8 at 0x7d080001a5c8 by thread T6:
>> #0 memset <null>:0
>> #1 lldb_private::HostNativeThreadBase::Reset()
>> tools/lldb/source/Host/common/HostNativeThreadBase.cpp:54
>> #2 lldb_private::HostThread::Reset()
>> tools/lldb/source/Host/common/HostThread.cpp:41
>> #3 lldb_private::Process::RunPrivateStateThread()
>> tools/lldb/source/Target/Process.cpp:4604
>> #4 lldb_private::Process::PrivateStateThread(void*)
>> tools/lldb/source/Target/Process.cpp:4505
>> #5 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*)
>> tools/lldb/source/Host/common/HostNativeThreadBase.cpp:81
>>
>> ==================
>> WARNING: ThreadSanitizer: data race (pid=64299)
>> Write of size 4 at 0x7d680001c8e8 by main thread:
>> #0 lldb_private::Terminal::SetFileDescriptor(int)
>> tools/lldb/include/lldb/Host/Terminal.h:46
>> #1 lldb_private::TerminalState::Save(int, bool)
>> tools/lldb/source/Host/common/Terminal.cpp:144
>> #2 lldb_private::Debugger::SaveInputTerminalState()
>> tools/lldb/source/Core/Debugger.cpp:825
>> #3 lldb::SBDebugger::SaveInputTerminalState()
>> tools/lldb/source/API/SBDebugger.cpp:395
>> #4 sigtstp_handler(int) tools/lldb/tools/driver/Driver.cpp:1203
>> #5 __tsan::CallUserSignalHandler(__tsan::ThreadState*, bool, bool,
>> int, my_siginfo_t*, void*) tsan_interceptors.o:0
>> #6 std::string::_Rep::_M_dispose(std::allocator<char> const&)
>> /build/buildd/gcc-4.8-4.8.2/build/x86_64-linux-gnu/libstdc++-v3/include/bits/basic_string.h:538
>> #7
>> lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&,
>> std::string&) tools/lldb/source/Interpreter/CommandInterpreter.cpp:2997
>> #8 non-virtual thunk to
>> lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&,
>> std::string&) tools/lldb/source/Interpreter/CommandInterpreter.cpp:3076
>> #9 lldb_private::IOHandlerEditline::Run()
>> tools/lldb/source/Core/IOHandler.cpp:729
>> #10 lldb_private::Debugger::ExecuteIOHandlers()
>> tools/lldb/source/Core/Debugger.cpp:907
>> #11 lldb_private::CommandInterpreter::RunCommandInterpreter(bool,
>> bool, lldb_private::CommandInterpreterRunOptions&)
>> tools/lldb/source/Interpreter/CommandInterpreter.cpp:3234
>> #12 lldb::SBDebugger::RunCommandInterpreter(bool, bool)
>> tools/lldb/source/API/SBDebugger.cpp:980
>> #13 Driver::MainLoop() tools/lldb/tools/driver/Driver.cpp:1152
>> #14 main tools/lldb/tools/driver/Driver.cpp:1252
>>
>> Previous write of size 4 at 0x7d680001c8e8 by thread T2 (mutexes: write
>> M159):
>> #0 lldb_private::Terminal::SetFileDescriptor(int)
>> tools/lldb/include/lldb/Host/Terminal.h:46
>> #1 lldb_private::TerminalState::Save(int, bool)
>> tools/lldb/source/Host/common/Terminal.cpp:144
>> #2 lldb_private::Debugger::SaveInputTerminalState()
>> tools/lldb/source/Core/Debugger.cpp:825
>> #3 lldb::SBDebugger::SaveInputTerminalState()
>> tools/lldb/source/API/SBDebugger.cpp:395
>> #4 sigtstp_handler(int) tools/lldb/tools/driver/Driver.cpp:1203
>> #5 __tsan::CallUserSignalHandler(__tsan::ThreadState*, bool, bool,
>> int, my_siginfo_t*, void*) tsan_interceptors.o:0
>> #6 lldb_private::Condition::Wait(lldb_private::Mutex&,
>> lldb_private::TimeValue const*, bool*)
>> tools/lldb/source/Host/common/Condition.cpp:85
>> #7 lldb_private::Predicate<bool>::WaitForValueEqualTo(bool,
>> lldb_private::TimeValue const*, bool*)
>> tools/lldb/include/lldb/Host/Predicate.h:339
>> #8
>> lldb_private::Listener::WaitForEventsInternal(lldb_private::TimeValue
>> const*, lldb_private::Broadcaster*, lldb_private::ConstString const*,
>> unsigned int, unsigned int, std::shared_ptr<lldb_private::Event>&)
>> tools/lldb/source/Core/Listener.cpp:442
>> #9 lldb_private::Listener::WaitForEvent(lldb_private::TimeValue
>> const*, std::shared_ptr<lldb_private::Event>&)
>> tools/lldb/source/Core/Listener.cpp:492
>> #10 lldb_private::Debugger::DefaultEventHandler()
>> tools/lldb/source/Core/Debugger.cpp:1623
>> #11 lldb_private::Debugger::EventHandlerThread(void*)
>> tools/lldb/source/Core/Debugger.cpp:1696
>> #12 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*)
>> tools/lldb/source/Host/common/HostNativeThreadBase.cpp:81
>>
>> ==================
>> WARNING: ThreadSanitizer: data race (pid=64299)
>> Write of size 4 at 0x7d680001c8ec by main thread:
>> #0 lldb_private::TerminalState::Save(int, bool)
>> tools/lldb/source/Host/common/Terminal.cpp:148
>> #1 lldb_private::Debugger::SaveInputTerminalState()
>> tools/lldb/source/Core/Debugger.cpp:825
>> #2 lldb::SBDebugger::SaveInputTerminalState()
>> tools/lldb/source/API/SBDebugger.cpp:395
>> #3 sigtstp_handler(int) tools/lldb/tools/driver/Driver.cpp:1203
>> #4 __tsan::CallUserSignalHandler(__tsan::ThreadState*, bool, bool,
>> int, my_siginfo_t*, void*) tsan_interceptors.o:0
>> #5 std::string::_Rep::_M_dispose(std::allocator<char> const&)
>> /build/buildd/gcc-4.8-4.8.2/build/x86_64-linux-gnu/libstdc++-v3/include/bits/basic_string.h:538
>> #6
>> lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&,
>> std::string&) tools/lldb/source/Interpreter/CommandInterpreter.cpp:2997
>> #7 non-virtual thunk to
>> lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&,
>> std::string&) tools/lldb/source/Interpreter/CommandInterpreter.cpp:3076
>> #8 lldb_private::IOHandlerEditline::Run()
>> tools/lldb/source/Core/IOHandler.cpp:729
>> #9 lldb_private::Debugger::ExecuteIOHandlers()
>> tools/lldb/source/Core/Debugger.cpp:907
>> #10 lldb_private::CommandInterpreter::RunCommandInterpreter(bool,
>> bool, lldb_private::CommandInterpreterRunOptions&)
>> tools/lldb/source/Interpreter/CommandInterpreter.cpp:3234
>> #11 lldb::SBDebugger::RunCommandInterpreter(bool, bool)
>> tools/lldb/source/API/SBDebugger.cpp:980
>> #12 Driver::MainLoop() tools/lldb/tools/driver/Driver.cpp:1152
>> #13 main tools/lldb/tools/driver/Driver.cpp:1252
>>
>> Previous write of size 4 at 0x7d680001c8ec by thread T2 (mutexes: write
>> M159):
>> #0 lldb_private::TerminalState::Save(int, bool)
>> tools/lldb/source/Host/common/Terminal.cpp:148
>> #1 lldb_private::Debugger::SaveInputTerminalState()
>> tools/lldb/source/Core/Debugger.cpp:825
>> #2 lldb::SBDebugger::SaveInputTerminalState()
>> tools/lldb/source/API/SBDebugger.cpp:395
>> #3 sigtstp_handler(int) tools/lldb/tools/driver/Driver.cpp:1203
>> #4 __tsan::CallUserSignalHandler(__tsan::ThreadState*, bool, bool,
>> int, my_siginfo_t*, void*) tsan_interceptors.o:0
>> #5 lldb_private::Condition::Wait(lldb_private::Mutex&,
>> lldb_private::TimeValue const*, bool*)
>> tools/lldb/source/Host/common/Condition.cpp:85
>> #6 lldb_private::Predicate<bool>::WaitForValueEqualTo(bool,
>> lldb_private::TimeValue const*, bool*)
>> tools/lldb/include/lldb/Host/Predicate.h:339
>> #7
>> lldb_private::Listener::WaitForEventsInternal(lldb_private::TimeValue
>> const*, lldb_private::Broadcaster*, lldb_private::ConstString const*,
>> unsigned int, unsigned int, std::shared_ptr<lldb_private::Event>&)
>> tools/lldb/source/Core/Listener.cpp:442
>> #8 lldb_private::Listener::WaitForEvent(lldb_private::TimeValue
>> const*, std::shared_ptr<lldb_private::Event>&)
>> tools/lldb/source/Core/Listener.cpp:492
>> #9 lldb_private::Debugger::DefaultEventHandler()
>> tools/lldb/source/Core/Debugger.cpp:1623
>> #10 lldb_private::Debugger::EventHandlerThread(void*)
>> tools/lldb/source/Core/Debugger.cpp:1696
>> #11 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*)
>> tools/lldb/source/Host/common/HostNativeThreadBase.cpp:81
>>
>>
>> -- Ryan Brown
>>
>> On Mon, May 11, 2015 at 8:20 AM, Ed Maste <emaste at freebsd.org> wrote:
>>>
>>> On 11 May 2015 at 10:21, Pavel Labath <labath at google.com> wrote:
>>> >
>>> > BTW, I've noticed that PushIOHandler does not lock
>>> > m_input_reader_stack.GetMutex(), unlike PopIOHandler, and all other
>>> > functions which deal with handlers. Is that intentional? I think it
>>> > should lock the mutex as well.
>>>
>>> A slight tangent here, but there's a lot of dubious thread behaviour
>>> like this. One example I've run into is PR22611 - I see that if we set
>>> a prompt that fits in libc++'s short string optimization (that is, no
>>> more than 22 characters) it works fine, but as soon as the prompt is
>>> 23 characters long we end up pointing at uninitialized memory;
>>> presumably the race window is much larger in that case.
>>>
>>> Unfortunately TSan isn't fully functional on FreeBSD at the moment, so
>>> it's not that easy for me to find other cases like this with a
>>> systematic approach. I recall there was an effort to run LLDB under
>>> TSan on Linux some time ago, and that found a number of issues. Is
>>> anyone on the Linux side interested in picking that up again?
>>> _______________________________________________
>>> lldb-dev mailing list
>>> lldb-dev at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>>
>>
>> _______________________________________________
>> lldb-dev mailing list
>> lldb-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>
>
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>
More information about the lldb-dev
mailing list