https://github.com/python/cpython/commit/6cd2f356c371f6ce984c6030ab0f2dd8a1eae743 commit: 6cd2f356c371f6ce984c6030ab0f2dd8a1eae743 branch: 3.13 author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com> committer: vstinner <vstin...@python.org> date: 2025-02-20T16:30:46Z summary:
[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 568db400ff07240a5ed6f263af281405ccaec716) Co-authored-by: Collin Funk <collin.fu...@gmail.com> files: A Misc/NEWS.d/next/Build/2025-02-07-21-20-21.gh-issue-129838.fkuiEc.rst M Modules/faulthandler.c diff --git a/Misc/NEWS.d/next/Build/2025-02-07-21-20-21.gh-issue-129838.fkuiEc.rst b/Misc/NEWS.d/next/Build/2025-02-07-21-20-21.gh-issue-129838.fkuiEc.rst new file mode 100644 index 00000000000000..958460249a65b6 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2025-02-07-21-20-21.gh-issue-129838.fkuiEc.rst @@ -0,0 +1,2 @@ +Don't redefine ``_Py_NO_SANITIZE_UNDEFINED`` when compiling with a recent +GCC version and undefined sanitizer enabled. diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c index 2d16028a5232d0..d2ff555434cfc1 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -34,14 +34,15 @@ #define PUTS(fd, str) (void)_Py_write_noraise(fd, str, strlen(str)) -// clang uses __attribute__((no_sanitize("undefined"))) -// GCC 4.9+ uses __attribute__((no_sanitize_undefined)) -#if defined(__has_feature) // Clang +// Clang and GCC 9.0+ use __attribute__((no_sanitize("undefined"))) +#if defined(__has_feature) # if __has_feature(undefined_behavior_sanitizer) # define _Py_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize("undefined"))) # endif #endif -#if defined(__GNUC__) \ + +// GCC 4.9+ uses __attribute__((no_sanitize_undefined)) +#if !defined(_Py_NO_SANITIZE_UNDEFINED) && defined(__GNUC__) \ && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)) # define _Py_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize_undefined)) #endif _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com