Open antocuni opened 3 years ago
Is this issue tracking debugger
attachment hanging?
Reproducer
from pyflyby import debugger
def test():
x = 1
y = '123'
debugger(wait_for_attach=True)
return x + y
test()
Attaching a debugger hangs:
$ ssh -t <hostname> /usr/local/python/python-3.10/std/bin/py -d 4157723
Entering debugger. Use 'n' to step, 'c' to continue running, 'q' to quit Python completely.
<HANGS>
This is problem which I ran into while trying to reproduce #131:
i.e., the
py
script just hangs indefinitely while trying to attach a debugger:_dbg.attach_debugger()
is implemented by spawning agdb -p <PID>
command, which tries to attach gdb to an existing processgdb -p
works by usingptrace
If I try to run
gdb -p
manually, this is what happens:So, I think that what happens under the hood is the following:
attach_debugger
spawnsgdb
The solution is to enable ptrace globally. After running the following command,
py -d
works again:I think that the proper behavior for
attach_debugger
should be to detect this case and warn the user. E.g.:/proc/sys/kernel/yama/ptrace_scope
and emit a clear error message, with links to the relevant documentation and maybe suggest to run the command above_dbg.inject()
to read and parse the output of the gdb commands