-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Multiple reference leaks in curses
error-branches
#123290
Labels
Comments
picnixz
added
type-bug
An unexpected behavior, bug, or error
extension-modules
C modules in the Modules dir
labels
Aug 24, 2024
picnixz
changed the title
Multiple error checks branches leak in
Multiple reference leaks in Sep 3, 2024
curses
curses
This was referenced Sep 11, 2024
gh-123290: curses: fix reference leaks in error-branches and cleanup module's initialization
#123910
Closed
vstinner
pushed a commit
that referenced
this issue
Sep 11, 2024
picnixz
changed the title
Multiple reference leaks in
Multiple reference leaks in Sep 11, 2024
curses
curses
error-branches
I'll keep the issue opened until we decide whether to backport the changes or not one by one, or in one go (there will be subsequent modifications on the curses module). |
The code is old and nobody reported issues about ref leaks. IMO the change is too big to be backported. I don't think that it's worth it to backport it. I close the issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug report
Bug description:
In
_cursesmodule.c
, we haveHowever,
PyDict_SetItemString
does not steal a reference. If the dict insertion fails for whatever reason,o
must be decref, which is not the case here. Similarly, inPyInit__curses
, a module object is explicitly created viaPyModule_Create
but is not decref if an error occurs:cpython/Modules/_cursesmodule.c
Line 4766 in b178bee
There are also calls that are not checked against errors:
cpython/Modules/_cursesmodule.c
Lines 4808 to 4811 in b178bee
Here, insertion is assumed to always succeed, but this may not be the case, in which case we shouldn't continue.
On the other hand, the
PyCursesWindowType
leaks since it's never cleared. While it does not matter if you exit the interpreter, I think it may matter if you just want to unload the module and continue with a normal execution.There are also other bugs that are more generally related to error-handling where some pointers might be NULL but are used as if they were not NULL, e.g. #123913).
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
_cursesmodule.c
#123953_cursesmodule.c
#124767The text was updated successfully, but these errors were encountered: