Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-46070: Fix asyncio initialisation guard#30423
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
erlend-aasland commented Jan 5, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
If init flag is set, exit successfully immediately. If not, only set the flag after successful initialisation.
erlend-aasland commented Jan 5, 2022
Maybe we should run this through the buildbots. |
erlend-aasland commented Jan 5, 2022
This might qualify for a NEWS entry, as it fixes segfaults on 3.10 and 3.9 (and 3.8, but 3.8 is in security-fix-mode-only). |
vstinner commented Jan 7, 2022
module_init() is called in parallel multiple times from different interpreters (in different threads). I understand that module_init() leaks references when calling multiple times in parallel, since it doesn't use |
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.
erlend-aasland commented Jan 7, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Yes, there are ref leaks, but as you say they are best fixed by converting global state to module state and implement proper multi-phase init. I've got a private branch for this work. This demands a separate bpo issue, and we should involve the asyncio maintaner before continuing with that effort :) Thanks for reviewing! |
vstinner commented Jan 7, 2022
Oh, I didn't notice the failing "news" job. Yes, please document the fix. If I understand correctly, this change fix a crash an importing the asyncio module from different sub-interpreters in parallel. And the workaround was to import asyncio in the main interpreter before spawning sub-interpreters. |
erlend-aasland commented Jan 7, 2022
Sure, I'll try to write something sensible :) Also, we could probably use a more compact version of your reproducer as a regression test. |
vstinner commented Jan 7, 2022
Adding a test is optional for me. It's up to me. But I would like to see a NEWS entry please. |
erlend-aasland commented Jan 7, 2022
You got it 🥁 |
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.
miss-islington commented Jan 7, 2022
Thanks @erlend-aasland for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10. |
If init flag is set, exit successfully immediately. If not, only set the flag after successful initialization. (cherry picked from commit b127e70) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
bedevere-bot commented Jan 7, 2022
GH-30453 is a backport of this pull request to the 3.10 branch. |
If init flag is set, exit successfully immediately. If not, only set the flag after successful initialization. (cherry picked from commit b127e70) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
bedevere-bot commented Jan 7, 2022
GH-30454 is a backport of this pull request to the 3.9 branch. |
If init flag is set, exit module init successfully immediately.
If not, only set the flag after successful module initialisation.
https://bugs.python.org/issue46070