https://github.com/python/cpython/commit/b38cfb7bcaa88b8036856b1e3d333fc1119786bb
commit: b38cfb7bcaa88b8036856b1e3d333fc1119786bb
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-04-01T12:35:58+02:00
summary:
gh-146479: Skip test_frame_pointer_unwind for gcc -O3 --enable-shared (#147947)
Skip the test if Python is built with --enable-shared and "gcc -O2"
or "gcc -O3".
files:
M Lib/test/test_frame_pointer_unwind.py
diff --git a/Lib/test/test_frame_pointer_unwind.py
b/Lib/test/test_frame_pointer_unwind.py
index 5804cc7e1d7f12..c70ec281686715 100644
--- a/Lib/test/test_frame_pointer_unwind.py
+++ b/Lib/test/test_frame_pointer_unwind.py
@@ -25,13 +25,19 @@ def _frame_pointers_expected(machine):
)
if value
)
+
if "no-omit-frame-pointer" in cflags:
+ # For example, configure adds -fno-omit-frame-pointer if Python
+ # has perf trampoline (PY_HAVE_PERF_TRAMPOLINE) and Python is built
+ # in debug mode.
return True
if "omit-frame-pointer" in cflags:
return False
+
if sys.platform == "darwin":
# macOS x86_64/ARM64 always have frame pointer by default.
return True
+
if sys.platform == "linux":
if machine in {"aarch64", "arm64"}:
# 32-bit Linux is not supported
@@ -39,7 +45,21 @@ def _frame_pointers_expected(machine):
return None
return True
if machine == "x86_64":
+ final_opt = ""
+ for opt in cflags.split():
+ if opt.startswith('-O'):
+ final_opt = opt
+ if final_opt in ("-O0", "-Og", "-O1"):
+ # Unwinding works if the optimization level is low
+ return True
+
+ Py_ENABLE_SHARED =
int(sysconfig.get_config_var('Py_ENABLE_SHARED') or '0')
+ if Py_ENABLE_SHARED:
+ # Unwinding does crash using gcc -O2 or gcc -O3
+ # when Python is built with --enable-shared
+ return "crash"
return False
+
if sys.platform == "win32":
# MSVC ignores /Oy and /Oy- on x64/ARM64.
if machine == "arm64":
@@ -153,10 +173,14 @@ class FramePointerUnwindTests(unittest.TestCase):
def setUp(self):
super().setUp()
+
machine = platform.machine().lower()
expected = _frame_pointers_expected(machine)
if expected is None:
self.skipTest(f"unsupported architecture for frame pointer check:
{machine}")
+ if expected == "crash":
+ self.skipTest(f"test does crash on {machine}")
+
try:
_testinternalcapi.manual_frame_pointer_unwind()
except RuntimeError as exc:
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]