https://github.com/Teemperor updated https://github.com/llvm/llvm-project/pull/195816
>From bd2c6c3b54f2eabc3a2913777791efcf4e2bb80a Mon Sep 17 00:00:00 2001 From: Raphael Isemann <[email protected]> Date: Fri, 1 May 2026 10:41:43 +0100 Subject: [PATCH] [lldb][test] Move dotest processes to own group to avoid random SIGHUPs On macOS, LLDB's test suite randomly receives SIGHUP signals that stop the test suite early. The source of these SIGHUP's seems to be a bug in the kernel (most likely the job control). The exact steps for reproducing this are not clear, but I have a set of three tests of which two need to run concurrently for this to trigger: * TestDAP_runInTerminal * TestDAP_launch_io_integratedTerminal * TestDAP_launch_stdio_redirection_and_console I was also running UBSan on this build which may or may not be necessary to make this random failure more persistent. When these tests run, macOS job control will send SIGHUP to the process group of the spawned subprocesses in that test. As LIT is in the same process group, it also receives the SIGHUP and shuts down. This patch forces all spawned subprocess to its own process group. This won't stop the SIGHUP and only prevents it from reaching LIT or dotest. This change is applied to all dotest processes as we saw similar failures before DAP tests were introduced. The SIGHUP itself doesn't seem to affect the DAP test itself. My theory here is that the SIGHUP is received during test shutdown (or after it was shut down), so that's why it doesn't cause any (visible) failures in any of the tests. --- lldb/packages/Python/lldbsuite/test/lldbtest.py | 10 ++++++++++ .../test/tools/lldb-server/gdbremote_testcase.py | 4 +++- .../commands/process/attach/TestProcessAttach.py | 10 +++++----- .../tools/lldb-server/commandline/TestStubSetSID.py | 13 ++++++++++--- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index f0eafba899c29..3bbd7a21edd51 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -434,6 +434,16 @@ def launch(self, executable, args, extra_env, **kwargs): stdout = kwargs.pop("stdout", DEVNULL if not self._trace_on else None) stderr = kwargs.pop("stderr", None) + # This works around a bug in the macOS job control code where + # a supurious SIGHUP is sent to the the process group of our + # spawned subprocess when it is shutting down. + # While this SIGHUP doesn't cause any issues for our subprocess, + # it does reach the LIT process and stops the test suite run + # early. + # This parameter forces the spawned process into a new process + # group which prevents the supurious SIGHUP from reaching LIT. + # We don't + kwargs.setdefault("start_new_session", True) self._proc = Popen( [executable] + args, diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py index 995dc6264d3ca..89cdf9760baa7 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -116,6 +116,7 @@ def setUp(self): self.setUpBaseLogging() self.debug_monitor_extra_args = [] + self.start_new_session = True if self.isVerboseLoggingRequested(): # If requested, full logs go to a log file @@ -364,7 +365,8 @@ def launch_debug_monitor(self, attach_pid=None, logfile=None): # Start the server. server = self.spawnSubprocess( - self.debug_monitor_exe, commandline_args, install_remote=False + self.debug_monitor_exe, commandline_args, install_remote=False, + start_new_session=self.start_new_session, ) self.assertIsNotNone(server) diff --git a/lldb/test/API/commands/process/attach/TestProcessAttach.py b/lldb/test/API/commands/process/attach/TestProcessAttach.py index 15d07737585aa..d0096280d9e68 100644 --- a/lldb/test/API/commands/process/attach/TestProcessAttach.py +++ b/lldb/test/API/commands/process/attach/TestProcessAttach.py @@ -30,7 +30,7 @@ def test_attach_to_process_by_id(self): exe = self.getBuildArtifact(exe_name) # Spawn a new process - popen = self.spawnSubprocess(exe) + popen = self.spawnSubprocess(exe, start_new_session=False) self.runCmd("process attach -p " + str(popen.pid)) @@ -46,7 +46,7 @@ def test_attach_to_process_by_id_autocontinue(self): exe = self.getBuildArtifact(exe_name) # Spawn a new process - popen = self.spawnSubprocess(exe) + popen = self.spawnSubprocess(exe, start_new_session=False) self.runCmd("process attach -c -p " + str(popen.pid)) @@ -67,7 +67,7 @@ def test_attach_to_process_from_different_dir_by_id(self): self.addTearDownHook(lambda: shutil.rmtree(newdir)) # Spawn a new process - popen = self.spawnSubprocess(exe) + popen = self.spawnSubprocess(exe, start_new_session=False) os.chdir(newdir) sourcedir = self.getSourceDir() @@ -85,7 +85,7 @@ def test_attach_to_process_by_name(self): exe = self.getBuildArtifact(exe_name) # Spawn a new process - popen = self.spawnSubprocess(exe) + popen = self.spawnSubprocess(exe, start_new_session=False) self.runCmd("process attach -n " + exe_name) @@ -108,7 +108,7 @@ def test_attach_to_process_by_id_correct_executable_offset(self): exe = self.getBuildArtifact(exe_name) # In order to reproduce, we must spawn using a relative path - popen = self.spawnSubprocess(os.path.relpath(exe)) + popen = self.spawnSubprocess(os.path.relpath(exe), start_new_session=False) self.runCmd("process attach -p " + str(popen.pid)) diff --git a/lldb/test/API/tools/lldb-server/commandline/TestStubSetSID.py b/lldb/test/API/tools/lldb-server/commandline/TestStubSetSID.py index 41bed72b56189..6b3eb0dc45bd5 100644 --- a/lldb/test/API/tools/lldb-server/commandline/TestStubSetSID.py +++ b/lldb/test/API/tools/lldb-server/commandline/TestStubSetSID.py @@ -20,10 +20,17 @@ def get_stub_sid(self, extra_stub_args=None): # Get the process id for the stub. return os.getsid(server.pid) + def prepare_test(self): + # Disable putting the target process into a new group/sid as we + # check whether the target is the same/different sid as us. + self.start_new_session = False + self.set_inferior_startup_launch() + + @skipIfWindows @skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target def test_sid_is_same_without_setsid(self): - self.set_inferior_startup_launch() + self.prepare_test() stub_sid = self.get_stub_sid() self.assertEqual(stub_sid, os.getsid(0)) @@ -31,7 +38,7 @@ def test_sid_is_same_without_setsid(self): @skipIfWindows @skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target def test_sid_is_different_with_setsid(self): - self.set_inferior_startup_launch() + self.prepare_test() stub_sid = self.get_stub_sid(["--setsid"]) self.assertNotEqual(stub_sid, os.getsid(0)) @@ -39,7 +46,7 @@ def test_sid_is_different_with_setsid(self): @skipIfWindows @skipIfRemote # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target def test_sid_is_different_with_S_llgs(self): - self.set_inferior_startup_launch() + self.prepare_test() stub_sid = self.get_stub_sid(["-S"]) self.assertNotEqual(stub_sid, os.getsid(0)) _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
