Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,9 @@ extern "C" {
# define _Py_NO_SANITIZE_THREAD __attribute__((no_sanitize_thread))
# endif
# endif
# if __has_feature(undefined_behavior_sanitizer)
# define _Py_NO_SANITIZE_FUNCTION __attribute__((no_sanitize("function")))
# endif
#elif defined(__GNUC__)
# if defined(__SANITIZE_ADDRESS__)
# define _Py_ADDRESS_SANITIZER
Expand All @@ -597,6 +600,9 @@ extern "C" {
#ifndef _Py_NO_SANITIZE_MEMORY
# define _Py_NO_SANITIZE_MEMORY
#endif
#ifndef _Py_NO_SANITIZE_FUNCTION
# define _Py_NO_SANITIZE_FUNCTION
#endif
#ifndef _Py_MSAN_UNPOISON
# define _Py_MSAN_UNPOISON(PTR, SIZE)
#endif
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_perf_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
if not support.has_subprocess_support:
raise unittest.SkipTest("test module requires subprocess")

if support.check_sanitizer(address=True, memory=True, ub=True, function=True):
if support.check_sanitizer(address=True, memory=True, function=False):
# gh-109580: Skip the test because it does crash randomly if Python is
# built with ASAN.
raise unittest.SkipTest("test crash randomly on ASAN/MSAN/UBSAN build")
raise unittest.SkipTest("test crash randomly on ASAN/MSAN build")


def supports_trampoline_profiling():
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_samply_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
if not support.has_subprocess_support:
raise unittest.SkipTest("test module requires subprocess")

if support.check_sanitizer(address=True, memory=True, ub=True, function=True):
if support.check_sanitizer(address=True, memory=True, function=False):
# gh-109580: Skip the test because it does crash randomly if Python is
# built with ASAN.
raise unittest.SkipTest("test crash randomly on ASAN/MSAN/UBSAN build")
raise unittest.SkipTest("test crash randomly on ASAN/MSAN build")


def supports_trampoline_profiling():
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix a crash in the perf trampoline (:option:`-X perf <-X>`) on builds with
clang's ``-fsanitize=function``, which ``-fsanitize=undefined`` enables
since clang 17.
3 changes: 2 additions & 1 deletion Python/perf_trampoline.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ compile_trampoline(void)
return code_arena_new_code(perf_code_arena);
}

static PyObject *
// gh-161288: the trampoline has no -fsanitize=function type signature
static PyObject * _Py_NO_SANITIZE_FUNCTION
py_trampoline_evaluator(PyThreadState *ts, _PyInterpreterFrame *frame,
int throw)
{
Expand Down
Loading