[all-commits] [llvm/llvm-project] 82ba3f: Recommit "[lldb/test] Don't use preexec_fn for lau...

Pavel Labath via All-commits all-commits at lists.llvm.org
Thu Jul 7 05:39:11 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 82ba3f44657ac91b4bef95dbf647dfbab482e502
      https://github.com/llvm/llvm-project/commit/82ba3f44657ac91b4bef95dbf647dfbab482e502
  Author: Pavel Labath <pavel at labath.sk>
  Date:   2022-07-07 (Thu, 07 Jul 2022)

  Changed paths:
    M lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
    M lldb/packages/Python/lldbsuite/test/lldbtest.py
    R lldb/test/API/tools/lldb-server/TestGdbRemoteAttachWait.py
    A lldb/test/API/tools/lldb-server/attach-wait/Makefile
    A lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py
    A lldb/test/API/tools/lldb-server/attach-wait/main.cpp
    A lldb/test/API/tools/lldb-server/attach-wait/shim.cpp

  Log Message:
  -----------
  Recommit "[lldb/test] Don't use preexec_fn for launching inferiors"

This recommits b15b1421, which reverted in was reverted in f51c47d98 due to
failures on apple systems. The problem was that the patch introduced a race
where the debug server could start the attach process before the first process
(which isn't supposed to be attached to) was set up. This caused us to attach
to the wrong process.

The new version introduces additional synchronization to ensure that does not
happen.

Original commit message was:
As the documentation states, using this is not safe in multithreaded
programs, and I have traced it to a rare deadlock in some of the tests.

The reason this was introduced was to be able to attach to a program
from the very first instruction, where our usual mechanism of
synchronization -- waiting for a file to appear -- does not work.

However, this is only needed for a single test
(TestGdbRemoteAttachWait) so instead of doing this everywhere, I create
a bespoke solution for that single test. The solution basically
consists of outsourcing the preexec_fn code to a separate (and
single-threaded) shim process, which enables attaching and then executes
the real program.

This pattern could be generalized in case we needed to use it for other
tests, but I suspect that we will not be having many tests like this.

This effectively reverts commit
a997a1d7fbe229433fb458bb0035b32424ecf3bd.




More information about the All-commits mailing list