multiprocessing.popen_spawn_posix
does not close child fds after spawn, can hang
#118981
Labels
type-bug
An unexpected behavior, bug, or error
multiprocessing.popen_spawn_posix
does not close child fds after spawn, can hang
#118981
Bug report
Bug description:
cpython/Lib/multiprocessing/popen_spawn_posix.py
Lines 51 to 72 in a705c1e
What happens here:
This order is wrong and can lead to hangs when the child proc crashes in between for whatever reason. Specifically, when the client crashes, then the parent will hang while trying to write into the parent fd, in this line:
cpython/Lib/multiprocessing/popen_spawn_posix.py
Line 62 in a705c1e
(I have this case because of some unpickling error happening in the child, but that's not really the point of the issue here.)
The fix should be easy: Add extra code to close the child fds, right after the spawn. This is also the standard pattern for this kind of code.
Also reported here: rwth-i6/returnn#1514
CPython versions tested on:
CPython main branch, CPython 3.11
Operating systems tested on:
Linux, Other
Linked PRs
The text was updated successfully, but these errors were encountered: