<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115618>115618</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[lldb] The test TestCancelAttach.py hangs on Windows host with Linux target
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lldb
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
slydiman
</td>
</tr>
</table>
<pre>
Issue 1:
TestCancelAttach.py, line 33
The call `self.target.AttachToProcessWithName(lldb.SBListener(), "LLDB-No-Such-Process", True, self.error)` in the AttachThread never return in case of Windows host and Linux target.
Issue 2:
The test failed here
```
if thread.is_alive():
self.fail("The attach thread is alive after timeout interval")
```
but the main thread will still wait for the AttachThread until timeout 10 min.
The issue 1 is most important.
The callstack on local Windows is the following
```
return Status::FromErrorString("attach by name is not supported");
lldb_private::Process::DoAttachToProcessWithName(const char * process_name, const lldb_private::ProcessAttachInfo & attach_info) at \llvm-project\lldb\include\lldb\Target\Process.h(1011)
lldb_private::Process::Attach(lldb_private::ProcessAttachInfo & attach_info) at \llvm-project\lldb\source\Target\Process.cpp(2983)
lldb_private::PlatformWindows::Attach(lldb_private::ProcessAttachInfo & attach_info, lldb_private::Debugger & debugger, lldb_private::Target * target, lldb_private::Status & error) at \llvm-project\lldb\source\Plugins\Platform\Windows\PlatformWindows.cpp(562)
lldb_private::Target::Attach(lldb_private::ProcessAttachInfo & attach_info, lldb_private::Stream * stream) at \llvm-project\lldb\source\Target\Target.cpp(3526)
AttachToProcess(lldb_private::ProcessAttachInfo & attach_info, lldb_private::Target & target) at \llvm-project\lldb\source\API\SBTarget.cpp(94)
lldb::SBTarget::AttachToProcessWithName(lldb::SBListener & listener, const char * name, bool wait_for, lldb::SBError & error) at \llvm-project\lldb\source\API\SBTarget.cpp(519)
_wrap_SBTarget_AttachToProcessWithName(_object * self, _object * args) at \tools\lldb\bindings\python\LLDBWrapPython.cpp(65404)
```
The callstack in case of Windows host and Linux target is the following
```
m_events_condition.wait(lock);
lldb_private::Listener::GetEventInternal(const lldb_private::Timeout<std::ratio<1,1000000>> & timeout, lldb_private::Broadcaster * broadcaster, unsigned int event_type_mask, std::shared_ptr<lldb_private::Event> & event_sp) at \llvm-project\lldb\source\Utility\Listener.cpp(275)
lldb_private::Listener::GetEventForBroadcasterWithType(lldb_private::Broadcaster * broadcaster, unsigned int event_type_mask, std::shared_ptr<lldb_private::Event> & event_sp, const lldb_private::Timeout<std::ratio<1,1000000>> & timeout) at \llvm-project\lldb\source\Utility\Listener.cpp(300)
lldb_private::Process::GetStateChangedEvents(std::shared_ptr<lldb_private::Event> & event_sp, const lldb_private::Timeout<std::ratio<1,1000000>> & timeout, std::shared_ptr<lldb_private::Listener> hijack_listener_sp) at \llvm-project\lldb\source\Target\Process.cpp(980)
lldb_private::Process::WaitForProcessToStop(const lldb_private::Timeout<std::ratio<1,1000000>> & timeout, std::shared_ptr<lldb_private::Event> * event_sp_ptr, bool wait_always, std::shared_ptr<lldb_private::Listener> hijack_listener_sp, lldb_private::Stream * stream, bool use_run_lock, SelectMostRelevant select_most_relevant) at \llvm-project\lldb\source\Target\Process.cpp(690)
lldb_private::Target::Attach(lldb_private::ProcessAttachInfo & attach_info, lldb_private::Stream * stream) at \llvm-project\lldb\source\Target\Target.cpp(3551)
AttachToProcess(lldb_private::ProcessAttachInfo & attach_info, lldb_private::Target & target) at \llvm-project\lldb\source\API\SBTarget.cpp(94)
lldb::SBTarget::AttachToProcessWithName(lldb::SBListener & listener, const char * name, bool wait_for, lldb::SBError & error) at \llvm-project\lldb\source\API\SBTarget.cpp(519)
_wrap_SBTarget_AttachToProcessWithName(_object * self, _object * args) at \tools\lldb\bindings\python\LLDBWrapPython.cpp(65404)
```
Note `process_sp = platform_sp->Attach(attach_info, GetDebugger(), this, error);` at \llvm-project\lldb\source\Target\Target.cpp(3526)
runs gdbserver and puts `vAttachWait` command with `LLDB-No-Such-Process` to the event queue. But this packet never sent to the target. Something is wrong with listeners/broadcasters.
Unfortunately I cannot debug (compare) it on Linux host right now.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWF9v4zgO_zTKi9DAlmNP8pCHJmkHBeYGg0sX82jINmNrK0s-iU4u3_4gWXbbnbSXne3iboEtiiTWH4r88WeSIrdW1ApgTdINSXcz3mOjzdrKcyVarmaFrs7rB2t7oDFJbkm0I9HtI1jcclWCvEXkZTPvzoRtqRQKaJKENQ3QkktJSRZZkIc5clMDzocdj_qb0SVY-11g85W3QNhSyqqY7zdfhEVQYAhbErZycgljX77sNjdf9c2-L5ubsJUw5mYfTQ_u2x8CxmjjtmURFYpiAzQc2BjgFVVwBEMNYG-UW1ByC1Qf6HehKn2ytNEWKVcV_SJU_28adB4sGj4HLNgzFg1QBIv0wIWEijZgIKzPovDvH8WBoldiLmzOpThCsHCURCkdjHCS_BxzwrnXP-ylwlK_l_IDgqEoWtA9UqEQzJFLj8nq4vlFjx6PlntgvLSTkJJadJ8nLpAetPkRs16hkNNJcURboV5B4rQUA0Wcfq3DULSdNsgVzulrPljk5RPVikpdcjkBL6w_-KCl1Ceh6osmBL_tkWNvHW7J7b3R7Z1z-h6N2-ZhC5AVZ6p463SjSiO1fed0giqAlGwGqY53eWfEkSMMQkeC-YedfpuypVYWadlwQwm7pd2wIFd-dkuH6TflD3If1EFTwrLg6FyogyZsRTlSkm6lPLY3ndG_Qon-sSpIuhWqlH0FzwOPnqgk3QbR84awZRzF8cSG_2LloEt4Cz9YW6t7U8IlLcuuI2zJVsvkPT0lx4M2baDKR-i7veCUHRR9XYPxq6vwcHnpYId3-RAhLi8beOrljXHpOpy-yb4Wyvpfg-0k3Y7mPw-GkYBimrF3QAzQ_0nY7dEAbz0g1v_8_ZQYfgRbkpRlkzG_ef0-Uu_JkdnkyCv1vv32QNLtfvNK7dXilQcCNpsfsX8r_Y07xhzoNZNTQhwjyhRwxkBTaD1E8PygJ86Ownx4_AkWXjQxjVeTjfnJ8C4fF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