8000 gh-111178: fix UBSan failures in `Modules/posixmodule.c` by picnixz · Pull Request #129788 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-111178: fix UBSan failures in Modules/posixmodule.c #129788

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 8 commits into from
Feb 24, 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.

Copy link
Member
@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM

@picnixz picnixz requested review from encukou and vstinner February 22, 2025 09:48
@picnixz
Copy link
Member Author
picnixz commented Feb 22, 2025

There was a redundant cast that I missed. I also renamed some parameters that I incorrectly renamed (using Py_UNUSED(ignored) is useless, it doesn't tell you at first glance whether it's a NOARGS or a ONEARG/VARARGS method while Py_UNUSED(dummy), Py_UNUSED(arg) and Py_UNUSED(args) would tell you more).

@encukou encukou merged commit de13293 into python:main Feb 24, 2025
41 checks passed
@encukou
Copy link
Member
encukou commented Feb 24, 2025

using Py_UNUSED(ignored) is useless, it doesn't tell you at first glance whether it's a NOARGS or a ONEARG/VARARGS method while Py_UNUSED(dummy), Py_UNUSED(arg) and Py_UNUSED(args) would tell you more

FWIW, I'm skeptical here -- I don't think we can make it reliably tell you more. But, if it doesn't matter, why not use your suggestions.

@picnixz
Copy link
Member Author
picnixz commented Feb 24, 2025

don't think we can make it reliably tell you more

The thing is that I saw one usage of void *ignored although it should have been PyObject *unused (#130446), however this was hidden behind a #ifdef MS_WINDOWS and removing the PyCFunction cast introduced a compilation error that I didn't see. For me "ignored" or "unused" means that we can possibly use the argument later. However "dummy" really means for me "it's just a placeholder, we'll never use it later" (I'm only using dummy for NOARGS method, not for VARARGS that actually ignore their args value).

The semantic change I usually do is unused to closure because the closure parameter is generally really for getter/setter and not for methods.

@picnixz picnixz deleted the fix/ubsan/posix-111178 branch February 24, 2025 12:50
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 2025
…nGH-129788)

Fix UBSan failures for `DirEntry`, `ScandirIterator`
Use better semantic naming
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.

3 participants
0