Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-129838: Don't redefine _Py_NO_SANITIZE_UNDEFINED#129839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
gh-129838: Don't redefine _Py_NO_SANITIZE_UNDEFINED#129839
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Newer GCC versions accept both __attribute__((no_sanitize("undefined")))and __attribute__((no_sanitize_undefined)) so check that the macro isnot already defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Looks good to me, thanks for contributing :)
Did you test against old and new gcc versions?
Good point. I just tested two which use different versions of the macro and work correctly. On my host machine:
On cfarm117 [1]:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM
568db40
intopython:mainUh oh!
There was an error while loading.Please reload this page.
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. |
GH-130365 is a backport of this pull request to the3.12 branch. |
GH-130366 is a backport of this pull request to the3.13 branch. |
Merged, thanks for the fix@collinfunk! |
#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 isnot already defined.(cherry picked from commit568db40)Co-authored-by: Collin Funk <collin.funk1@gmail.com>
#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 isnot already defined.(cherry picked from commit568db40)Co-authored-by: Collin Funk <collin.funk1@gmail.com>
Uh oh!
There was an error while loading.Please reload this page.
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