Skip to content

Commit 568db40

Browse files
authored
pythongh-129838: Don't redefine _Py_NO_SANITIZE_UNDEFINED (python#129839)
Newer GCC versions accept both __attribute__((no_sanitize("undefined"))) and __attribute__((no_sanitize_undefined)) so check that the macro is not already defined.
1 parent 0f5b821 commit 568db40

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
@@ -37,14 +37,15 @@
3737
#define PUTS(fd, str) (void)_Py_write_noraise(fd, str, strlen(str))
3838

3939

40-
// clang uses __attribute__((no_sanitize("undefined")))
41-
// GCC 4.9+ uses __attribute__((no_sanitize_undefined))
42-
#if defined(__has_feature) // Clang
40+
// Clang and GCC 9.0+ use __attribute__((no_sanitize("undefined")))
41+
#if defined(__has_feature)
4342
# if __has_feature(undefined_behavior_sanitizer)
4443
# define _Py_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize("undefined")))
4544
# endif
4645
#endif
47-
#if defined(__GNUC__) \
46+
47+
// GCC 4.9+ uses __attribute__((no_sanitize_undefined))
48+
#if !defined(_Py_NO_SANITIZE_UNDEFINED) && defined(__GNUC__) \
4849
&& ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 9))
4950
# define _Py_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize_undefined))
5051
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy