From b335875942efa7bfc2b54106da6d73c24e3d7808 Mon Sep 17 00:00:00 2001 From: Cody Maloney Date: Wed, 20 Nov 2024 17:21:07 -0800 Subject: [PATCH 1/3] gh-127076: Disable strace tests under LD_PRELOAD Distribution tooling (ex. sandbox on Gentoo and fakeroot on Debian) uses LD_PRELOAD to intercept system calls and potentially modify them when building. These tools can change the set of system calls, so disable system call testing under these cases. --- Lib/test/support/strace_helper.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/test/support/strace_helper.py b/Lib/test/support/strace_helper.py index 7fb4581b2a7390..8c38efc9813ee4 100644 --- a/Lib/test/support/strace_helper.py +++ b/Lib/test/support/strace_helper.py @@ -1,6 +1,7 @@ import re import sys import textwrap +import os import unittest from dataclasses import dataclass from functools import cache @@ -163,6 +164,13 @@ def requires_strace(): if sys.platform != "linux": return unittest.skip("Linux only, requires strace.") + if 'LD_PRELOAD' in os.environ: + # Distribution packaging (ex. Debian `fakeroot` and Gentoo `sandbox`) + # use LD_PRELOAD to intercept system calls, which changes the overall + # set of system calls which breaks tests expecting a specific set of + # system calls). + return unittest.skip("Not supported when LD_PRELOAD is intercepting system calls.") + if support.check_sanitizer(address=True, memory=True): return unittest.skip("LeakSanitizer does not work under ptrace (strace, gdb, etc)") From 4b2538b1025e9cc25287d78f78a1cfaae6eaa152 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 02:03:50 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Tests/2024-11-21-02-03-48.gh-issue-127076.a3avV1.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Tests/2024-11-21-02-03-48.gh-issue-127076.a3avV1.rst diff --git a/Misc/NEWS.d/next/Tests/2024-11-21-02-03-48.gh-issue-127076.a3avV1.rst b/Misc/NEWS.d/next/Tests/2024-11-21-02-03-48.gh-issue-127076.a3avV1.rst new file mode 100644 index 00000000000000..7dec8bd627c063 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2024-11-21-02-03-48.gh-issue-127076.a3avV1.rst @@ -0,0 +1 @@ +Disable strace based system call tests when LD_PRELOAD is set. From 7e2c69e61e5eeeecc7c4e1029d24be531cc4b74a Mon Sep 17 00:00:00 2001 From: Cody Maloney Date: Wed, 20 Nov 2024 21:17:31 -0800 Subject: [PATCH 3/3] Update Lib/test/support/strace_helper.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michał Górny --- Lib/test/support/strace_helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/support/strace_helper.py b/Lib/test/support/strace_helper.py index 8c38efc9813ee4..90281b47274299 100644 --- a/Lib/test/support/strace_helper.py +++ b/Lib/test/support/strace_helper.py @@ -164,7 +164,7 @@ def requires_strace(): if sys.platform != "linux": return unittest.skip("Linux only, requires strace.") - if 'LD_PRELOAD' in os.environ: + if "LD_PRELOAD" in os.environ: # Distribution packaging (ex. Debian `fakeroot` and Gentoo `sandbox`) # use LD_PRELOAD to intercept system calls, which changes the overall # set of system calls which breaks tests expecting a specific set of