Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
bpo-40550: Fix time-of-check/time-of-action issue in subprocess.Popen.send_signal.#20010
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 ourterms of service andprivacy 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
ZackerySpytz left a comment• 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.
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.
I'm not sure if this PR will be accepted, but I left some comments.
Also, this PR should probably have a unit test.
Uh oh!
There was an error while loading.Please reload this page.
Misc/NEWS.d/next/Library/2020-05-08-21-30-54.bpo-40550.i7GWkb.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
FFY00 commentedMay 14, 2020
This fixes a race condition, there's no way to reliably have a unit test. The process needs to exit between the return code check and the action itself. |
remilapeyre commentedMay 14, 2020
I think you could write a unit test by synchronising the threads so the race condition occurs. You can mock |
remilapeyre 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.
Hi@FFY00, I checked the test and it simulates the race condition successfully 👍
Try not to force-push during reviews thought as it makes it harder to see what has been updated since the last time one viewed that changes.
Uh oh!
There was an error while loading.Please reload this page.
FFY00 commentedMay 14, 2020 • 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.
You can click on |
Signed-off-by: Filipe Laíns <lains@archlinux.org>
FFY00 commentedMay 14, 2020
Sorry, after writing all that I messed up the git history 😕 You can still view the correct diff here:https://github.com/python/cpython/compare/49e7004bc963966bfb2f264d6022ef4477f21bcc..3d7dfbc1c19280dd19693d8d8e0574590c0c1bee |
FFY00 commentedJun 19, 2020
@gpshead do you have a minute to review this? |
Uh oh!
There was an error while loading.Please reload this page.
The ProcessLookupError already means errno == ESRCH.
miss-islington commentedNov 21, 2020
….send_signal. (pythonGH-20010)send_signal() now swallows the exception if the process it thought was still alive winds up not to exist anymore (always a plausible race condition despite the checks).Co-authored-by: Gregory P. Smith <greg@krypto.org>(cherry picked from commit01a202a)Co-authored-by: Filipe Laíns <lains@archlinux.org>
bedevere-bot commentedNov 21, 2020
GH-23439 is a backport of this pull request to the3.9 branch. |
miss-islington commentedNov 21, 2020
Sorry,@FFY00 and@gpshead, I could not cleanly backport this to |
….send_signal. (GH-20010)send_signal() now swallows the exception if the process it thought was still alive winds up not to exist anymore (always a plausible race condition despite the checks).Co-authored-by: Gregory P. Smith <greg@krypto.org>(cherry picked from commit01a202a)Co-authored-by: Filipe Laíns <lains@archlinux.org>
….send_signal. (pythonGH-20010)send_signal() now swallows the exception if the process it thought was still alive winds up not to exist anymore (always a plausible race condition despite the checks).Co-authored-by: Gregory P. Smith <greg@krypto.org>
Note that we call Popen.poll/wait in the event loop thread to avoidPopen's thread-unsafety. Without this workaround, when testing_ThreadedChildWatcher with the reproducer shared in the linked issue on mymachine:* Case 1 of the known race condition ignored inpythonGH-20010 is met (and an unsafe kill call is issued) about 1 in 10 times.* The race conditionpythonGH-127050 is met (causing _process_exited's assert returncode is not None to raise) about 1 in 30 times.
Uh oh!
There was an error while loading.Please reload this page.
All the implementation details have been explained the bug, please check it out.
https://bugs.python.org/issue40550