gh-129838: Don't redefine _Py_NO_SANITIZE_UNDEFINED#129839
Merged
vstinner merged 1 commit intopython:mainfrom Feb 20, 2025
collinfunk:no-sanitize-undefined-redefinition
Merged
gh-129838: Don't redefine _Py_NO_SANITIZE_UNDEFINED#129839vstinner merged 1 commit intopython:mainfrom collinfunk:no-sanitize-undefined-redefinition
vstinner merged 1 commit intopython:mainfrom
collinfunk:no-sanitize-undefined-redefinition
Conversation
Newer GCC versions accept both __attribute__((no_sanitize("undefined")))
and __attribute__((no_sanitize_undefined)) so check that the macro is
not already defined.
zanieb
approved these changes
Feb 8, 2025
Contributor
zanieb
left a comment
There was a problem hiding this comment.
Looks good to me, thanks for contributing :)
Did you test against old and new gcc versions?
Contributor
Author
Good point. I just tested two which use different versions of the macro and work correctly. On my host machine: On cfarm117 [1]: |
|
Thanks @collinfunk for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
|
Thanks @collinfunk for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Feb 20, 2025
|
GH-130365 is a backport of this pull request to the 3.12 branch. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Feb 20, 2025
|
GH-130366 is a backport of this pull request to the 3.13 branch. |
Member
|
Merged, thanks for the fix @collinfunk! |
vstinner
pushed a commit
that referenced
this pull request
Feb 20, 2025
#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>
vstinner
pushed a commit
that referenced
this pull request
Feb 20, 2025
#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 <collin.funk1@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This macro is redefined because the code was written at a time when LLVM supported:
and GCC supported:
In 2018, GCC (then 9.0.0) was updated to also accept the LLVM syntax [1]. Since __has_feature was added to GCC in 2023 we can assume
__has_feature(undefined_behavior_sanitizer)being true also means__attribute__((no_sanitize("undefined")))is supported.Then we just check that the macro isn't defined before checking for the GCC version to use the older syntax.
[1] gcc-mirror/gcc@1991606