FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-83004: Clean up refleaks in ssl, socket initialisation by hauntsaninja · Pull Request #99044 · python/cpython · GitHub

/ cpython Public

gh-83004: Clean up refleaks in ssl, socket initialisation - #99044

Closed
hauntsaninja wants to merge 2 commits into
python:mainfrom
hauntsaninja:gh-83004-sslsocket
Closed

gh-83004: Clean up refleaks in ssl, socket initialisation#99044
hauntsaninja wants to merge 2 commits into
python:mainfrom
hauntsaninja:gh-83004-sslsocket

Conversation

hauntsaninja commented Nov 3, 2022
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Contributor

Comment thread Modules/_ssl.c
PyObject *bool_obj = (value) ? Py_True : Py_False; \
Py_INCREF(bool_obj); \
PyModule_AddObject((m), (key), bool_obj); \
PyModule_AddObjectRef((m), (key), bool_obj); \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Isn't this still a leak because we're not checking the return value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It's no longer a leak.

The thing that makes PyModule_AddObject tricky cause leaks is that you have to decref in the failure case, but not in the success case (because it steals the ref). With PyModule_AddObjectRef you can treat the failure and success cases the same in terms of what they do to ref counts.

But yes, in general we should probably be propagating failures here, and the other cases below you commented on. I didn't do it in this PR because it's a slightly separate change and there are many other places in this module where we don't check return values.

hauntsaninja Nov 6, 2022
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Should I check return values for just the ones I'm touching in this PR or fix all of them?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for the explanation! I feel it'd be fine to also fix missing error checks in this PR, since the change remains localized and you're fixing a very similar problem to what the PR already fixes.

Comment thread Modules/socketmodule.c
Comment thread Modules/socketmodule.c
#endif
Py_INCREF(has_ipv6);
PyModule_AddObject(m, "has_ipv6", has_ipv6);
PyModule_AddObjectRef(m, "has_ipv6", has_ipv6);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Check the return value.

Comment thread Modules/socketmodule.c
if (tmp == NULL)
return NULL;
PyModule_AddObject(m, names[i], tmp);
PyModule_AddObjectRef(m, names[i], tmp);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Here too.

Copy link
Copy Markdown
Contributor

The socket issues have been resolved in gh-103261.

erlend-aasland commented Feb 8, 2024
edited
Loading

Copy link
Copy Markdown
Contributor

_ssl.c issues were resolved as part of #106858 and #111232.

Copy link
Copy Markdown
Contributor

Closing, as the issues have been resolved in other PRs. Thanks :)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

4 participants


Back | FazBrowse Home | New Git URL