Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged

Conversation

collinfunk
Copy link
Contributor

@collinfunkcollinfunk commentedFeb 8, 2025
edited by bedevere-appbot
Loading

This macro is redefined because the code was written at a time when LLVM supported:

__attribute__((no_sanitize("undefined")))

and GCC supported:

__attribute__((no_sanitize_undefined))

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

Newer GCC versions accept both __attribute__((no_sanitize("undefined")))and __attribute__((no_sanitize_undefined)) so check that the macro isnot already defined.
Copy link
Contributor

@zaniebzanieb left a 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?

@collinfunk
Copy link
ContributorAuthor

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:

$ gcc --versiongcc (GCC) 14.2.1 20250110 (Red Hat 14.2.1-7)

On cfarm117 [1]:

$ gcc --versiongcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516

[1]https://portal.cfarm.net/machines/list/

zanieb reacted with heart emoji

Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM

@vstinnervstinner merged commit568db40 intopython:mainFeb 20, 2025
52 checks passed
@vstinnervstinner added needs backport to 3.12only security fixes needs backport to 3.13bugs and security fixes labelsFeb 20, 2025
@miss-islington-app
Copy link

Thanks@collinfunk for the PR, and@vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@miss-islington-app
Copy link

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 requestFeb 20, 2025
…29839)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>
@bedevere-app
Copy link

GH-130365 is a backport of this pull request to the3.12 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.12only security fixes labelFeb 20, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestFeb 20, 2025
…29839)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>
@bedevere-app
Copy link

GH-130366 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelFeb 20, 2025
@vstinner
Copy link
Member

Merged, thanks for the fix@collinfunk!

collinfunk reacted with laugh emoji

vstinner pushed a commit that referenced this pull requestFeb 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 isnot already defined.(cherry picked from commit568db40)Co-authored-by: Collin Funk <collin.funk1@gmail.com>
vstinner pushed a commit that referenced this pull requestFeb 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 isnot already defined.(cherry picked from commit568db40)Co-authored-by: Collin Funk <collin.funk1@gmail.com>
@collinfunkcollinfunk deleted the no-sanitize-undefined-redefinition branchFebruary 20, 2025 18:42
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@vstinnervstinnervstinner approved these changes

@zaniebzaniebzanieb approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@collinfunk@vstinner@zanieb

[8]ページ先頭

©2009-2025 Movatter.jp