[issue29335] Python 2.7 subprocess module does not check WIFSTOPPED on SIGCHLD
New submission from Zach Riggle: The attached script hits some "This should never happen" code in the subprocess module. These lines here: https://github.com/python/cpython/blob/2.7/Lib/subprocess.py#L1036-L1038 The root cause is a lack of checking WIFSTOPPED and WSTOPSIG in the handler. When a process elects into being ptraced via PTRACE_TRACEME, it is stopped on the SIGSEGV instead of terminating, allowing the user to attach a debugger before the kernel destroys the process. This bug makes it impossible to wait on any process which crashes, which is set up to wait for a debugger. -- components: Library (Lib) files: bug.py messages: 285921 nosy: Zach Riggle priority: normal severity: normal status: open title: Python 2.7 subprocess module does not check WIFSTOPPED on SIGCHLD versions: Python 2.7 Added file: http://bugs.python.org/file46363/bug.py ___ Python tracker <http://bugs.python.org/issue29335> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29335] Python 2.7 subprocess module does not check WIFSTOPPED on SIGCHLD
Zach Riggle added the comment: To further clarify the report: When the attached proof-of-concept is executed, a RuntimeException is raised, which has a comment "Should never happen". The issue isn't due to SIGCHLD, but rather following a waitpid() call. The code attempts to suss the exit code / reason for waitpid() returning, but does not check for WIFSTOPPED in its handler. -- ___ Python tracker <http://bugs.python.org/issue29335> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29335] subprocess module does not check WIFSTOPPED on SIGCHLD
Zach Riggle added the comment: Of note, there's no need to actually cause a SIGSEGV to generate the signal. The tests might be more clear to replace: libc.printf(ctypes.c_char_p(0xdeadbeef)) with os.kill(os.getpid(), signal.SIGSEGV) -- ___ Python tracker <http://bugs.python.org/issue29335> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29335] subprocess module does not check WIFSTOPPED on SIGCHLD
Zach Riggle added the comment: Neat, though that's not in the standard library. The current logic for getting a handle to libc could also be simplified via ctypes.util.find_library (https://docs.python.org/3/library/ctypes.html#finding-shared-libraries). Darwin: >>> import ctypes.util >>> ctypes.util.find_library('c') '/usr/lib/libc.dylib' Linux: >>> import ctypes.util >>> ctypes.util.find_library('c') 'libc.so.6' -- ___ Python tracker <http://bugs.python.org/issue29335> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com