[New-bugs-announce] [issue20318] subprocess.Popen can hang in threaded applications

Andrew Lutomirski report at bugs.python.org
Mon Jan 20 21:30:19 CET 2014

New submission from Andrew Lutomirski:

Running python python_thread_bug.py -j4 often results in one of the threads failing to start until another thread finishes.

The bug appears to be that subprocess's pipe_cloexec function is racy: if another thread forks between os.pipe() and _set_cloexec_flag, then the resulting process could hang on to the write end of the pipe.  That will cause the Popen call that got rudely interrupted to wait until the whole resulting process tree dies.

components: Library (Lib)
files: python_thread_bug.py
messages: 208577
nosy: Andrew.Lutomirski
priority: normal
severity: normal
status: open
title: subprocess.Popen can hang in threaded applications
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file33571/python_thread_bug.py

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list