Skip to content
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

gh-111178: fix UBSan failures in Objects/exceptions.c #128154

Merged
merged 25 commits into from
Feb 17, 2025

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented Dec 21, 2024

@picnixz picnixz marked this pull request as draft January 14, 2025 10:56
@picnixz picnixz marked this pull request as ready for review January 14, 2025 10:59
@picnixz picnixz marked this pull request as draft February 7, 2025 10:35
@picnixz picnixz marked this pull request as ready for review February 7, 2025 10:35
@picnixz picnixz changed the title gh-111178: fix UBSan failures for exception types gh-111178: fix UBSan failures in Modules/exceptions.c Feb 7, 2025
@picnixz picnixz changed the title gh-111178: fix UBSan failures in Modules/exceptions.c gh-111178: fix UBSan failures in Objects/exceptions.c Feb 7, 2025
@picnixz picnixz marked this pull request as draft February 8, 2025 13:24
@picnixz picnixz marked this pull request as ready for review February 8, 2025 13:27
@picnixz
Copy link
Member Author

picnixz commented Feb 8, 2025

@encukou I've used static inline functions here (because having the assert would actually make the macro more unreadable than anything as the names are very long), but this is a bit inconsistent with the rest of the PRs. I haven't converted one macro into a static inline function because it's not the only one (so I preferred to minimize the diff) but I guess the compiler will be smart enough (I put an explicit inline keyword and I guess it will be smart enough to make the inlining but I can check if you think it's important for performance)

Comment on lines +668 to +674
0, BaseException_dealloc, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, \
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, \
PyDoc_STR(EXCDOC), (traverseproc)BaseException_traverse, \
(inquiry)BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \
PyDoc_STR(EXCDOC), BaseException_traverse, \
BaseException_clear, 0, 0, 0, 0, 0, 0, 0, &_ ## EXCBASE, \
0, 0, 0, offsetof(PyBaseExceptionObject, dict), \
(initproc)BaseException_init, 0, BaseException_new,\
BaseException_init, 0, BaseException_new,\
Copy link
Member

Choose a reason for hiding this comment

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

While you're touching these, (introducing conflicts with any in-flight PR, and adding yourself to git blame), could you switch to named initializers?
Feel free to do it in a follow-up PR if you want to merge this one soon.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I've said it in another PR, but Serhiy asked for a discussion on DPO (which never happened I think) in #127679 and you asked for it to be included in PEP-7 first so I left those out (especially for static types like these; I think I touched some heap types and internal ones never exposed, but I don't think I touched something that was publicly exposed).

Copy link
Member Author

Choose a reason for hiding this comment

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

Feel free to do it in a follow-up PR if you want to merge this one soon.

For UBSan failures, I expect them to be merged whenever it's fine to merge them. I just have a bunch of branches that I ignore when I do git branch (otherwise I just have too many of them locally). And I don't mind solving conflicts

Copy link
Member

Choose a reason for hiding this comment

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

For changing them all at once, it IMO should definitely go in PEP-7. In the usual case there's nothing wrong with the "old" syntax, and we generally avoid style-only changes.

In this case though, the style is a lot less readable than usual -- it's missing the comment column, and it has more items per line. Since you are touching this anyway (so backports will conflict, etc.), this is the time to clean it up.

I'll merge this PR; feel free to follow up.

@encukou encukou merged commit 7ea8927 into python:main Feb 17, 2025
47 checks passed
@picnixz picnixz deleted the fix/ubsan/exceptions-111178 branch February 17, 2025 10:10
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