8000 [3.12] gh-129838: Don't redefine _Py_NO_SANITIZE_UNDEFINED (GH-129839… · python/cpython@f314cc4 · GitHub
[go: up one dir, main page]

Skip to content

Commit f314cc4

Browse files
[3.12] gh-129838: Don't redefine _Py_NO_SANITIZE_UNDEFINED (GH-129839) (#130365)
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 <collin.funk1@gmail.com>
1 parent 5c0aba0 commit f314cc4

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed
Lines changed: 2 additions & 0 deletions
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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@
2929
#define PUTS(fd, str) _Py_write_noraise(fd, str, strlen(str))
3030

3131

32-
// clang uses __attribute__((no_sanitize("undefined")))
33-
// GCC 4.9+ uses __attribute__((no_sanitize_undefined))
34-
#if defined(__has_feature) // Clang
32+
// Clang and GCC 9.0+ use __attribute__((no_sanitize("undefined")))
33+
#if defined(__has_feature)
3534
# if __has_feature(undefined_behavior_sanitizer)
3635
# define _Py_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize("undefined")))
3736
# endif
3837
#endif
39-
#if defined(__GNUC__) \
38+
39+
// GCC 4.9+ uses __attribute__((no_sanitize_undefined))
40+
#if !defined(_Py_NO_SANITIZE_UNDEFINED) && defined(__GNUC__) \
4041
&& ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 9))
4142
# define _Py_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize_undefined))
4243
#endif

0 commit comments

Comments
 (0)
0