aboutsummaryrefslogtreecommitdiff
path: root/lldb/packages/Python/lldbsuite
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2022-07-01 14:32:50 +0200
committerPavel Labath <pavel@labath.sk>2022-07-01 14:36:01 +0200
commitb15b1421bc9a11b318b65b489e5fd58dd917db1f (patch)
tree7956491226784f96588468855b83ae4c9d24dac5 /lldb/packages/Python/lldbsuite
parentfabe915705472e2c06ed1aa9a90620462594e82f (diff)
downloadllvm-b15b1421bc9a11b318b65b489e5fd58dd917db1f.zip
llvm-b15b1421bc9a11b318b65b489e5fd58dd917db1f.tar.gz
llvm-b15b1421bc9a11b318b65b489e5fd58dd917db1f.tar.bz2
[lldb/test] Don't use preexec_fn for launching inferiors
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.
Diffstat (limited to 'lldb/packages/Python/lldbsuite')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbplatformutil.py14
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbtest.py1
2 files changed, 1 insertions, 14 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index e14c4f8..719131c 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -4,12 +4,11 @@ architecture and/or the platform dependent nature of the tests. """
from __future__ import absolute_import
# System modules
-import ctypes
import itertools
-import os
import re
import subprocess
import sys
+import os
# Third-party modules
import six
@@ -192,14 +191,3 @@ def hasChattyStderr(test_case):
if match_android_device(test_case.getArchitecture(), ['aarch64'], range(22, 25+1)):
return True # The dynamic linker on the device will complain about unknown DT entries
return False
-
-if getHostPlatform() == "linux":
- def enable_attach():
- """Enable attaching to _this_ process, if host requires such an action.
- Suitable for use as a preexec_fn in subprocess.Popen and similar."""
- c = ctypes.CDLL(None)
- PR_SET_PTRACER = ctypes.c_int(0x59616d61)
- PR_SET_PTRACER_ANY = ctypes.c_ulong(-1)
- c.prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY)
-else:
- enable_attach = None
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 2285173..d46e54f 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -393,7 +393,6 @@ class _LocalProcess(_BaseProcess):
stdout=open(
os.devnull) if not self._trace_on else None,
stdin=PIPE,
- preexec_fn=lldbplatformutil.enable_attach,
env=env)
def terminate(self):