Skip to content

Commit 6cd2f35

Browse files
[3.13] gh-129838: Don't redefine _Py_NO_SANITIZE_UNDEFINED (GH-129839) (#130366)
gh-129838: Don't redefine _Py_NO_SANITIZE_UNDEFINED (GH-129839) Newer GCC versions accept both __attribute__((no_sanitize("undefined"))) and __attribute__((no_sanitize_undefined)) so check that the macro is not already defined. (cherry picked from commit 568db40) Co-authored-by: Collin Funk <[email protected]>
1 parent 38dfe01 commit 6cd2f35

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Don't redefine ``_Py_NO_SANITIZE_UNDEFINED`` when compiling with a recent
2+
GCC version and undefined sanitizer enabled.

Modules/faulthandler.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@
3434
#define PUTS(fd, str) (void)_Py_write_noraise(fd, str, strlen(str))
3535

3636

37-
// clang uses __attribute__((no_sanitize("undefined")))
38-
// GCC 4.9+ uses __attribute__((no_sanitize_undefined))
39-
#if defined(__has_feature) // Clang
37+
// Clang and GCC 9.0+ use __attribute__((no_sanitize("undefined")))
38+
#if defined(__has_feature)
4039
# if __has_feature(undefined_behavior_sanitizer)
4140
# define _Py_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize("undefined")))
4241
# endif
4342
#endif
44-
#if defined(__GNUC__) \
43+
44+
// GCC 4.9+ uses __attribute__((no_sanitize_undefined))
45+
#if !defined(_Py_NO_SANITIZE_UNDEFINED) && defined(__GNUC__) \
4546
&& ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 9))
4647
# define _Py_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize_undefined))
4748
#endif

0 commit comments

Comments
 (0)