https://github.com/python/cpython/commit/39d10e306f4c59514ba2f26dbfa4ac774fb63b42
commit: 39d10e306f4c59514ba2f26dbfa4ac774fb63b42
branch: 3.15
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-11-10T00:10:54Z
summary:

[3.15] gh-111178: Set function=False by default in support.check_sanitizer() 
(#161640) (#161713)

gh-111178: Set function=False by default in support.check_sanitizer() (#161640)

Update also libregrtest.utils to detect function sanitizer
(-fsanitize=function).

(cherry picked from commit 4e10d4fef5c073faaaf04ce5e03749a5dbe7716b)

files:
M Lib/test/libregrtest/utils.py
M Lib/test/support/__init__.py

diff --git a/Lib/test/libregrtest/utils.py b/Lib/test/libregrtest/utils.py
index 6d4e23bb8624f3..50c7b7c00d14ef 100644
--- a/Lib/test/libregrtest/utils.py
+++ b/Lib/test/libregrtest/utils.py
@@ -403,6 +403,9 @@ def get_build_info():
     # --with-thread-sanitizer
     if support.check_sanitizer(thread=True):
         sanitizers.append("TSAN")
+    # --with-thread-sanitizer
+    if support.check_sanitizer(function=True):
+        sanitizers.append("fsanitize=function")
     if sanitizers:
         build.append('+'.join(sanitizers))
 
@@ -691,6 +694,7 @@ def display_header(use_resources: dict[str, str | None],
     msan = support.check_sanitizer(memory=True)
     ubsan = support.check_sanitizer(ub=True)
     tsan = support.check_sanitizer(thread=True)
+    function_san = support.check_sanitizer(function=True)
     sanitizers = []
     if asan:
         sanitizers.append("address")
@@ -700,12 +704,14 @@ def display_header(use_resources: dict[str, str | None],
         sanitizers.append("undefined behavior")
     if tsan:
         sanitizers.append("thread")
+    if function_san:
+        sanitizers.append("function")
     if sanitizers:
         print(f"== sanitizers: {', '.join(sanitizers)}")
         for sanitizer, env_var in (
             (asan, "ASAN_OPTIONS"),
             (msan, "MSAN_OPTIONS"),
-            (ubsan, "UBSAN_OPTIONS"),
+            (ubsan or function_san, "UBSAN_OPTIONS"),
             (tsan, "TSAN_OPTIONS"),
         ):
             options= os.environ.get(env_var)
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 209cee1b760af1..389215153385b5 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -438,10 +438,11 @@ def skip_if_buildbot(reason=None):
     return unittest.skipIf(isbuildbot, reason)
 
 def check_sanitizer(*, address=False, memory=False, ub=False, thread=False,
-                    function=True):
+                    function=False):
     """Returns True if Python is compiled with sanitizer support"""
-    if not (address or memory or ub or thread):
-        raise ValueError('At least one of address, memory, ub or thread must 
be True')
+    if not (address or memory or ub or thread or function):
+        raise ValueError('At least one of address, memory, ub, '
+                         'thread or function must be True')
 
 
     cflags = sysconfig.get_config_var('CFLAGS') or ''
@@ -486,11 +487,13 @@ def configured_with_sanitizer(name):
     )
 
 
-def skip_if_sanitizer(reason=None, *, address=False, memory=False, ub=False, 
thread=False):
+def skip_if_sanitizer(reason=None, *, address=False, memory=False, ub=False,
+                      thread=False, function=False):
     """Decorator raising SkipTest if running with a sanitizer active."""
     if not reason:
         reason = 'not working with sanitizers active'
-    skip = check_sanitizer(address=address, memory=memory, ub=ub, 
thread=thread)
+    skip = check_sanitizer(address=address, memory=memory, ub=ub,
+                           thread=thread, function=function)
     return unittest.skipIf(skip, reason)
 
 # gh-89363: True if fork() can hang if Python is built with Address Sanitizer

_______________________________________________
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]

Reply via email to