[strace/strace] Strace should prevent a process under tracing to attach to the strace itself (#178)

Igor Zhbanov notifications at github.com
Mon Mar 29 15:59:17 UTC 2021

There is a problem when mutual debugging of 2 processes can stuck in unkillable stopped state.

When one process, let's say "A", is tracing the another process "B", and the process "B" is trying to attach to the process "A", then both of them are getting stuck in the "t+" state. And they are ignoring all of the signals including the SIGKILL, so it is not possible to terminate them without a reboot.

To reproduce:
1) Open two terminals.
2) Attach with `strace -p ...` from the first terminal to the shell (bash) of the second terminal.
3) In the second terminal run `exec strace -p ...` to attach to the PID of the first strace.

Then you'll see that the second strace is hanging without any output. And the first strace will output following and hang too:
(The 11795 is the PID of the first strace itself.)

And in the process list you will see following:
ps awux | grep strace
user   11776  0.0  0.0  24752  2248 pts/3    t+   13:53   0:00 strace -p 11795
user   11795  0.0  0.0  24752  3888 pts/1    t+   13:54   0:00 strace -p 11776

I've sent a letter to linux-trace-devel mailing list. But the strace itself is able to forbid to attaching to itself, at least when it sees such an attempt.

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20210329/f774aee3/attachment.htm>

More information about the Strace-devel mailing list