Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 33.9k
bpo-36356: Fix memory leak in _asynciomodule.c during "setup.py build_ext"#16598
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
btharper commented Oct 5, 2019 • edited by bedevere-bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-bot
Uh oh!
There was an error while loading. Please reload this page.
1st1 commented Oct 5, 2019
I think you should add a |
btharper commented Oct 6, 2019
Turns out I was incorrect about the double import. It's importing itself as part of the import process, once as "_asyncio" that then imports itself as "asyncio" gdb trace (with edited paths) below. The spec is passed in from setup.py line 529, but the _module naming convention doesn't seem out of place compared to others (_sha*, _ctypes, _decimal, etc). #0 module_init () at cpython/Modules/_asynciomodule.c:3251 |
btharper commented Oct 6, 2019
Updated with a static variable to check initialization. left initialization for the inner call and return early for the outside call, although I don't think the difference would be significant. If everything looks good I can squash the previous commit since the first one is entirely reverted by the second. |
Uh oh!
There was an error while loading. Please reload this page.
1st1 commented Oct 7, 2019
LGTM, but please fix the nit I highlighted. |
Co-Authored-By: Yury Selivanov <[email protected]>
btharper commented Oct 7, 2019
Good catch, I've fixed the one introduced by this changeset, but grep shows 6 more instances. Would it be worth fixing them along with these changes, or leaving it as it is? |
vstinner commented Oct 7, 2019
@btharper: Which instances? In which file? |
btharper commented Oct 7, 2019 • edited by bedevere-bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-bot
Uh oh!
There was an error while loading. Please reload this page.
Sorry for the lack of specificity. 6 more instances of the closing bracket being on the same line as an else/else if in the Modules/_asynciomodule.c file. I wasn't sure if it would be useful to clean up the rest of the file or just correct what was modified in this PR, though I expect not changing unrelated lines is the safest answer. Anything else for bpo-36356 would be under another PR. |
1st1 commented Oct 7, 2019 • edited by bedevere-bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-bot
Uh oh!
There was an error while loading. Please reload this page.
We can fix them in a separate PR. |
1st1 commented Oct 7, 2019
Could you please generate a NEWS entry with |
vstinner left a comment
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.
I'm fine with merging it with new NEWS entry. It's uncommon to load a C extension twice.
miss-islington commented Oct 7, 2019
(cherry picked from commit 321def8) Co-authored-by: Ben Harper <[email protected]>
1st1 commented Oct 7, 2019
Alright! |
bedevere-bot commented Oct 7, 2019
GH-16622 is a backport of this pull request to the 3.8 branch. |
(cherry picked from commit 321def8) Co-authored-by: Ben Harper <[email protected]>
The module seems to be imported twice during the build process which causes a leak. Since these objects are intended to be global for the life of the import, retain them during the second import.
The double import seems to be an artifact of the build system, and not indicative of normal use.
Multiple PRs for BPO-36356 were largely grouped under a single NEWS entry, should this continue to be skipped, or should a new note be added for the 3.9 branch?
https://bugs.python.org/issue36356