deshaw / pyflyby

A set of productivity tools for Python
https://deshaw.github.io/pyflyby/
Other
353 stars 52 forks source link

GDB exits and debugging stops with -d <pid> on a running process (PyInf#10417) #217

Open dshivashankar1994 opened 2 years ago

dshivashankar1994 commented 2 years ago

I noticed that here we exit the GDB launched using inject and the debugging happens outside of the GDB.

The code in here checks for the presence of the gdb process and exits the debugging if not.

The gdb process stops and becomes a zombie process. Earlier the issue was not exposed as the zombie process was not considered as non-existing - which was fixed in commit 6ee02b8af32e9c2a23ca286024d88380c3ba0403.

dshivashankar1994 commented 1 year ago

Expanding the issue a little bit

Because Zombie process are treated as existing (tried to solve in https://github.com/deshaw/pyflyby/commit/6ee02b8af32e9c2a23ca286024d88380c3ba0403), say we do 'py -d ' and while this is active we issue second 'py -d ' on the same pid, command hangs forever

Basically, GDB doesn't support connecting multiple GDB to same process and hence it exits when an active GDB is already connected with the process.

Couple of things to be modified to fix this issue are with inject method (here)

  1. PIPE the stdout and stderr to be used later instead of "_dev_null" (if show_output is False)
  2. Return process instead of process.id so that the process.stdout and process.stderr can be processed by the watchdog process

Since this is a public facing API, we should see how we can take care of the above changes as the signature gets modified with above change.