[Lldb-commits] [PATCH] D90313: [lldb] Use reverse connection method for lldb-server tests

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 28 08:14:29 PDT 2020


labath created this revision.
labath added reviewers: rupprecht, JDevlieghere.
Herald added a subscriber: jfb.
Herald added a project: LLDB.
labath requested review of this revision.

This fixes an flakyness is all gdb-remote tests. These tests have been
(mildly) flaky since we started using "localhost" instead of 127.0.0.1
in the test suite. The reason is that lldb-server needs to create two
sockets (v4 and v6) to listen for localhost connections. The algorithm
it uses first tries to select a random port (bind(localhost:0)) for the
first address, and then bind the same port for the second one.

The creating of the second socket can fail as there's no guarantee that
port will be available -- it seems that the (linux) kernel tries to
choose an unused port for the first socket (I've had to create thousands
of sockets to reproduce this reliably), but this can apparantly fail
when the system is under load (and our test suite creates a _lot_ of
sockets).

The socket creationg operation is considered successful if it creates at
least one socket is created, but the test harness has no way of knowing
which one it is, so it can end up connecting to the wrong address.

I'm not aware of a way to atomically create two sockets bound to the
same port. One way to fix this would be to make lldb-server report the
address is it listening on instead of just the port. However, this would
be a breaking change and it's not clear to me that's worth it (the
algorithm works pretty well under normal circumstances).

Instead, this patch sidesteps that problem by using "reverse"
connections. This way, the test harness is responsible for creating the
listening socket so it can pass the address that it has managed to open.
It also results in much simpler code overall.

To preserve test coverage for the named pipe method, I've moved the
relevant code to a dedicated test. To avoid original problem, this test
passes raw addresses (as obtained by getaddrinfo(localhost)) instead of
"localhost".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90313

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/test/API/tools/lldb-server/commandline/TestGdbRemoteConnection.py
  lldb/test/API/tools/lldb-server/commandline/TestStubReverseConnect.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90313.301291.patch
Type: text/x-patch
Size: 15549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20201028/cd3a6bff/attachment.bin>


More information about the lldb-commits mailing list