bin/178664: truss(1) may kill process
Jilles Tjoelker
jilles at stack.nl
Sun May 19 12:10:02 UTC 2013
The following reply was made to PR bin/178664; it has been noted by GNATS.
From: Jilles Tjoelker <jilles at stack.nl>
To: bug-followup at FreeBSD.org, kwiat3k at panic.pl
Cc:
Subject: Re: bin/178664: truss(1) may kill process
Date: Sun, 19 May 2013 14:09:32 +0200
In PR bin/178664, you wrote:
> [attaching truss(1) may terminate sleep(1) early]
What actually happens is that the nanosleep(2) system call fails with
[EINTR] immediately when the debugger (ptrace(2)) attaches. You can
verify this using ktrace(1).
This is really a longstanding known bug, although I don't know where it
is documented. It is longstanding because it is very hard to fix. The
kernel wants threads to return to the kernel-userspace boundary when a
debugger attaches, and this causes the state of the in-progress system
call to be lost. The effect is much like a signal with SA_RESTART set.
If you care about sleep(1) itself, that is easy to fix. It already
continues the sleep when nanosleep(2) was interrupted by SIGINFO; this
can be extended to any [EINTR] error.
A workaround is to use ktrace(1) instead of truss(1) or strace(1) from
ports. ktrace(1) generally affects the traced program much less.
--
Jilles Tjoelker
More information about the freebsd-bugs
mailing list