-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-111178: fix UBSan failures in Modules/_interp*module.c
#129779
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
Conversation
Ah I'm sorry I put this one as ready for review but I learned that _ + capital letter was also UB (#128248 (comment)) so I'll fix them tomorrow. |
It's not exactly UB, it's just that those names are reserved for the C standard. In practice, it's probably fine to leave it, and not worth the inconsistency/confusion of adding a |
The problem with |
Half the codebase is UB then! I understand the issue, but what's the actual chance that we'll get broken by prefixing something with |
The chance is probably almost zero but Petr wanted to avoid adding more UBs. So I guess it makes sense. By the way, I found it easier to actually type the macro without the leading underscore as well so it's also a good idea to actually ease writing! |
Half?
It is exactly UB. That's a hard fact. The C23 standard says:
Also yes. CPython is big enough that we can hope that compiler/libc authors won't actually use the In practice, new features in C nowadays tend to start with double-underscore or underscore+uppercase. Let's not use more of those -- especially in PRs that remove UB. (Speaking of technicalities: PEP-7 says “ |
Concerning the |
Not disagreeing, I'm just saying it's not UB in the same way that using uninitialized memory is UB. I'm just pointing out that messing around with it probably isn't worth the weird inconsistencies in our macros. There's no actual plan to remove |
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, with one question.
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.