bpo-33929: multiprocessing: fix handle leak on race condition#7921
Conversation
|
@pitrou: My first version was wrong, but I fixed it and now tests pass on AppVeyor and VSTS (Windows). Would you mind to review this change please? I'm not 100% sure that it's correct, but I'm now sure that the current code has a race condition :-) |
Sorry, something went wrong.
vstinner
left a comment
There was a problem hiding this comment.
I rebased my PR to be able to rewrite the commit message and update properly the NEWS entry.
Sorry, something went wrong.
bpo-33929: Fix a race condition in Popen of multiprocessing.popen_spawn_win32. The child process now duplicates the read end of pipe instead of "stealing" it. Previously, the read end of pipe was "stolen" by the child process, but it leaked a handle if the child process had been terminated before it could steal the handle from the parent process.
|
@pitrou: I fixed all the issues that you reported. Would you mind to review my updated PR? Thanks. By the way, I found a similar but different bug: https://bugs.python.org/issue33966 But it's a different code path, so I think that it's fine to fix it in a different PR. |
Sorry, something went wrong.
Ok, fair. I removed the comment. |
Sorry, something went wrong.
|
Thank you for unconfusing me :-) |
Sorry, something went wrong.
LOL |
Sorry, something went wrong.
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7. |
Sorry, something went wrong.
…GH-7921) Fix a race condition in Popen of multiprocessing.popen_spawn_win32. The child process now duplicates the read end of pipe instead of "stealing" it. Previously, the read end of pipe was "stolen" by the child process, but it leaked a handle if the child process had been terminated before it could steal the handle from the parent process. (cherry picked from commit 2cc9d21) Co-authored-by: Victor Stinner <vstinner@redhat.com>
|
Sorry, @vstinner, I could not cleanly backport this to |
Sorry, something went wrong.
|
Victor, I'm skeptical about backporting this. It's not an important issue and we risk introducing regressions in a bugfix release. Let's make it a 3.8-only change? |
Sorry, something went wrong.
I'm trying to understand why multiprocessing tests are failing randomly but also frequently, for one year (if not longer, 3 years?). Fixing race conditions should reduce random tests failures, but I'm not sure that leaking open Windows handles can explain these failures. About regression: IMHO the new code is less fragile and should not have no race condition. But I'm ok to not backport this change, except if someone proves that this change helps to make tests more stable :-) |
Sorry, something went wrong.
Fix a race condition in Popen of multiprocessing.popen_spawn_win32. The child process now duplicates the read end of pipe instead of "stealing" it. Previously, the read end of pipe was "stolen" by the child process, but it leaked a handle if the child process had been terminated before it could steal the handle from the parent process. (cherry picked from commit 2cc9d21) Co-authored-by: Victor Stinner <vstinner@redhat.com>
|
I rejected my 3.6 backport: PR 7961. But @miss-islington merged its 3.7 backport: PR #7960 :-( @pitrou: Should I revert the backport to 3.7? Maybe it's fine for the 3.7.1, since it's newer? |
Sorry, something went wrong.
Fix a race condition in Popen of
multiprocessing.popen_spawn_win32. The child process now duplicates
rhandle instead of "stealing" it.
Previously, rhandle was "stolen" by the child process, but it leaked
a handle if the child process has been terminated before it "stole"
the handle (and closed it in the parent process).
https://bugs.python.org/issue33929