Skip to content

gh-111178: fix UBSan failures in Modules/_functoolsmodule.c #129778

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 21, 2025

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented Feb 7, 2025

This PR fixes the UBSan failures and addresses some minor cosmetic changes. PEP-7 changes were not applied since they could scramble the diff but other semantic changes affecting the signature of touched functions may have been done.

In addition, change `_PyPartialObject_CAST` to `partialobject_CAST`
as `_` + capital letter is UB.
@picnixz picnixz marked this pull request as ready for review February 8, 2025 09:39
@picnixz picnixz requested a review from rhettinger as a code owner February 8, 2025 09:39
@@ -145,7 +145,7 @@ typedef struct {
} partialobject;

// cast a PyObject pointer PTR to a partialobject pointer (no type checks)
#define _PyPartialObject_CAST(PTR) ((partialobject *)(PTR))
#define partialobject_CAST(op) ((partialobject *)(op))
Copy link
Member

Choose a reason for hiding this comment

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

There' no need to change existing macros, especially ones with the _Py prefix that's de-facto reserved for Python.

Copy link
Member Author

Choose a reason for hiding this comment

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

Err actually this is something I probably wrote recently so I thought it would have been better to make it consistent at least. I can revert it though (I think that's my code because there is a PTR and this is something I used before Victor told me to use "op")

Copy link
Member

Choose a reason for hiding this comment

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

Oh, right, it's from #124733 from October

@encukou encukou merged commit 4f07fd5 into python:main Feb 21, 2025
43 checks passed
@picnixz picnixz deleted the fix/ubsan/functools-111178 branch February 21, 2025 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants