[Bug 34192] New: [5.0] check-lldb-unit hangs with lldb-server running

Bug ID 34192
Summary [5.0] check-lldb-unit hangs with lldb-server running
Product lldb
Version unspecified
Hardware PC
OS Linux
Status NEW
Severity enhancement
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter hahnjo@hahnjo.de
CC llvm-bugs@lists.llvm.org

As said in the title, check-lldb-unit hangs while a process 'lldb-server' is
still running and consuming 100% CPU.

If I run tools/lldb/unittests/tools/lldb-server/tests/LLDBServerTests manually,
I get:

[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from ThreadsInJstopinfoTest
[ RUN      ] ThreadsInJstopinfoTest.TestStopReplyContainsThreadPcsLlgs
lldb-server-local_buildConnection established.

[  INFO ]
<...>/src-5.0.0rc2/tools/lldb/unittests/tools/lldb-server/tests/TestClient.cpp:171::
Send Packet:
A214,0,2F746D702F6A683336363237362F636C75737465722D6870635F31373334342F6275696C642D352E302E307263322F66696E616C2F746F6F6C732F6C6C64622F756E697474657374732F746F6F6C732F6C6C64622D7365727665722F7468726561645F696E666572696F72,2,1,34
1502787553.110960007 <   1> read packet: +
1502787553.111004114 < 232> read packet:
$A214,0,2F746D702F6A683336363237362F636C75737465722D6870635F31373334342F6275696C642D352E302E307263322F66696E616C2F746F6F6C732F6C6C64622F756E697474657374732F746F6F6C732F6C6C64622D7365727665722F7468726561645F696E666572696F72,2,1,34#1a
1502787553.111036062 <   1> send packet: +
Launched
'<...>/build-5.0.0rc2/final/tools/lldb/unittests/tools/lldb-server/thread_inferior'
as process 31142...
1502787553.146780014 <   6> send packet: $OK#9a

[  INFO ]
<...>/src-5.0.0rc2/tools/lldb/unittests/tools/lldb-server/tests/TestClient.cpp:174::
Read Packet: OK

[  INFO ]
<...>/src-5.0.0rc2/tools/lldb/unittests/tools/lldb-server/tests/TestClient.cpp:171::
Send Packet: qLaunchSuccess
1502787553.146975040 <   1> read packet: +
1502787553.147003889 <  18> read packet: $qLaunchSuccess#a5
1502787553.147032976 <   1> send packet: +
1502787553.147064924 <   6> send packet: $OK#9a

[  INFO ]
<...>/src-5.0.0rc2/tools/lldb/unittests/tools/lldb-server/tests/TestClient.cpp:174::
Read Packet: OK

[  INFO ]
<...>/src-5.0.0rc2/tools/lldb/unittests/tools/lldb-server/tests/TestClient.cpp:171::
Send Packet: qProcessInfo
1502787553.147120953 <   1> read packet: +
1502787553.147138119 <  16> read packet: $qProcessInfo#dc
1502787553.147159100 <   1> send packet: +
1502787553.147363901 < 166> send packet:
$pid:79a6;parent-pid:79a4;real-uid:651e;real-gid:651e;effective-uid:651e;effective-gid:651e;triple:7838365f36342d2d6c696e7578;ostype:linux;endian:little;ptrsize:8;#1f

1502787553.147422075 <   1> read packet: +
[  INFO ]
<...>/src-5.0.0rc2/tools/lldb/unittests/tools/lldb-server/tests/TestClient.cpp:174::
Read Packet:
pid:79a6;parent-pid:79a4;real-uid:651e;real-gid:651e;effective-uid:651e;effective-gid:651e;triple:7838365f36342d2d6c696e7578;ostype:linux;endian:little;ptrsize:8;

[  INFO ]
<...>/src-5.0.0rc2/tools/lldb/unittests/tools/lldb-server/tests/TestClient.cpp:171::
Send Packet: QListThreadsInStopReply
1502787553.147484064 <  27> read packet: $QListThreadsInStopReply#21
1502787553.147500992 <   1> send packet: +
1502787553.147512913 <   6> send packet: $OK#9a

1502787553.147535086 <   1> read packet: +
[  INFO ]
<...>/src-5.0.0rc2/tools/lldb/unittests/tools/lldb-server/tests/TestClient.cpp:174::
Read Packet: OK

[  INFO ]
<...>/src-5.0.0rc2/tools/lldb/unittests/tools/lldb-server/tests/TestClient.cpp:171::
Send Packet: vCont;c
1502787553.147579908 <  11> read packet: $vCont;c#a8
1502787553.147593975 <   1> send packet: +
1502787553.147814035 < 443> send packet:
$O2f746d702f6a683336363237362f636c75737465722d6870635f31373334342f6275696c642d352e302e307263322f66696e616c2f746f6f6c732f6c6c64622f756e697474657374732f746f6f6c732f6c6c64622d7365727665722f7468726561645f696e666572696f723a206572726f72207768696c65206c6f6164696e6720736861726564206c69627261726965733a206c6962632b2b2e736f2e313a2063616e6e6f74206f70656e20736861726564206f626a6563742066696c653a204e6f20737563682066696c65206f72206469726563746f72790d0a#09

[  INFO ] 1502787553.147836924 <   1> read packet: +
<...>/src-5.0.0rc2/tools/lldb/unittests/tools/lldb-server/tests/TestClient.cpp:174::
Read Packet:
O2f746d702f6a683336363237362f636c75737465722d6870635f31373334342f6275696c642d352e302e307263322f66696e616c2f746f6f6c732f6c6c64622f756e697474657374732f746f6f6c732f6c6c64622d7365727665722f7468726561645f696e666572696f723a206572726f72207768696c65206c6f6164696e6720736861726564206c69627261726965733a206c6962632b2b2e736f2e313a2063616e6e6f74206f70656e20736861726564206f626a6563742066696c653a204e6f20737563682066696c65206f72206469726563746f72790d0a
1502787553.147871971 <   7> send packet: $W7f#f4

[ ERROR ]
<...>/src-5.0.0rc2/tools/lldb/unittests/tools/lldb-server/tests/TestClient.cpp:223::
Unable to parse StopReply: thread ID at [0].
<...>/src-5.0.0rc2/tools/lldb/unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp:33:
Failure
Value of: client.ContinueAll()
  Actual: false
Expected: true
[  FAILED  ] ThreadsInJstopinfoTest.TestStopReplyContainsThreadPcsLlgs (76 ms)
[----------] 1 test from ThreadsInJstopinfoTest (76 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (76 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] ThreadsInJstopinfoTest.TestStopReplyContainsThreadPcsLlgs

 1 FAILED TEST

labath@google.com changed bug 34192

What | Removed | Added |

Comment # 7 on bug 34192 from labath@google.com

(In reply to Jonas Hahnfeld from comment #6)
> (In reply to labath from comment #5)
> > I believe <[https://reviews.llvm.org/D39010](https://reviews.llvm.org/D39010)> will fix your problem, but I
> > can't tell for sure (as things were working for me in the first place). If
> > you have some time, I'd appreciate it if you can test it.
> 
> I think this works, but maybe for the wrong reasons: I build with the LLVM
> tree with Clang 4.0.1 and therefore have LD_LIBRARY_PATH with libc++ set. So
> it does not pick up the newly built library in <root>/lib/...

The purpose of the test is not to test the newly-built libc++. We just need
_any_ c++ library around to be able to run the inferior. So, we pick the c++
library that you build the rest of your toolchain with, since that has to be
around and working. In your case, we just happen to need LD_LIBRARY_PATH set in
order to use c++ library that we build with.

So, unless I misunderstood something, I think this solution is fine.