benfred / remoteprocess

Cross platform process information in Rust
MIT License
56 stars 29 forks source link

Fix race condition with ptrace+execve causing spurious SIGTRAP #82

Closed andrewjcg closed 1 year ago

andrewjcg commented 1 year ago

As per comment, there appears to be a potential race with a subprocess, where after the initial PTRACE_ATTACH, but before the process receives a SIGSTOP, it hits an execve and then triggers a SIGTRAP, which can cause the process to die. Details on ptrace+execve at: https://man7.org/linux/man-pages/man2/ptrace.2.html#:~:text=execve(2)%20under%20ptrace

This fixes by supressing the SIGTRAP (which should only be issued by debuggers).

andrewjcg commented 1 year ago

Ah, so I still see some other types of hangs/issues even with this fix.

I think https://github.com/benfred/remoteprocess/pull/83 is a more complete fix (and appears to fix all issues we see when running py-spy).