This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Child process deadlock in subprocess.Popen
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Zhipeng Xie, iritkatriel
Priority: normal Keywords:

Created on 2019-10-24 07:38 by Zhipeng Xie, last changed 2022-04-11 14:59 by admin. This issue is now closed.

File name Uploaded Description Edit Zhipeng Xie, 2019-10-24 07:38
Messages (2)
msg355290 - (view) Author: Zhipeng Xie (Zhipeng Xie) * Date: 2019-10-24 07:38
Hi, we had a child process deadlock on _disabling_gc_lock in subprocess.Popen. It seems that after, subprocess.Popen no longer support to be called in preexec_fn.

Steps to reproduce:
[root@localhost ~]# python2 --version
Python 2.7.15
[root@localhost ~]# python2 

wait for a while and the child process deadlock

Here is the gdb stack:

(gdb) py-bt
Traceback (most recent call first):
  Waiting for the GIL
  File "/usr/local/lib/python2.7/", line 931, in _execute_child
    with self._disabling_gc_lock:
  File "/usr/local/lib/python2.7/", line 394, in __init__
    errread, errwrite)
  File "", line 36, in run_cmd
  File "/usr/local/lib/python2.7/", line 989, in _execute_child
  File "/usr/local/lib/python2.7/", line 394, in __init__
    errread, errwrite)
  File "", line 15, in run_command
    stdout=arg_stdout, stderr=arg_stderr, shell=True)
  File "", line 51, in _readerthread3
    status = run_command("/root/exe",preexec_fn=preexec_fn_no_args)
  File "/usr/local/lib/python2.7/", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/", line 801, in __bootstrap_inner
  File "/usr/local/lib/python2.7/", line 774, in __bootstrap
(gdb) py-list
 926                # The first char specifies the exception type: 0 means
 927                # OSError, 1 means some other error.
 928                errpipe_read, errpipe_write = self.pipe_cloexec()
 929                try:
 930                    try:
>931                        with self._disabling_gc_lock:
 932                            gc_was_enabled = gc.isenabled()
 933                            # Disable gc to avoid bug where gc -> file_dealloc ->
 934                            # write to stderr -> hang.
 935                            #
 936                            gc.disable()
msg394656 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-05-28 13:10
Python 2.7 is no longer supported and the code of subprocess has been changed a lot compared to what shows up in your traceback. Please create a new issue if you still see this problem in Python 3.9+.
Date User Action Args
2022-04-11 14:59:22adminsetgithub: 82756
2021-05-28 13:10:08iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg394656

resolution: out of date
stage: resolved
2019-10-24 07:38:39Zhipeng Xiecreate