https://github.com/python/cpython/commit/4e10d4fef5c073faaaf04ce5e03749a5dbe7716b
commit: 4e10d4fef5c073faaaf04ce5e03749a5dbe7716b
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-11-10T00:25:19+01:00
summary:

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

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

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 0b8f7f51395a643..41a798c71089f9e 100644
--- a/Lib/test/libregrtest/utils.py
+++ b/Lib/test/libregrtest/utils.py
@@ -414,6 +414,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))
 
@@ -701,6 +704,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")
@@ -710,12 +714,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 df3ae0890c0f126..f69734037a8fe57 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -462,11 +462,11 @@ def skip_if_buildbot(reason=None):
     return unittest.skipIf(isbuildbot, reason)
 
 def check_sanitizer(*, address=False, hwaddress=False, memory=False, ub=False,
-                    thread=False, function=True):
+                    thread=False, function=False):
     """Returns True if Python is compiled with sanitizer support"""
-    if not (address or hwaddress or memory or ub or thread):
-        raise ValueError('At least one of address, hwaddress, memory, ub or '
-                         'thread must be True')
+    if not (address or hwaddress or memory or ub or thread or function):
+        raise ValueError('At least one of address, hwaddress, memory, ub, '
+                         'thread or function must be True')
 
 
     cflags = sysconfig.get_config_var('CFLAGS') or ''
@@ -517,11 +517,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