[patch] Break by Ctrl-C before first syscall SIGSTOPs the traced process

Roland McGrath roland at redhat.com
Sat Jun 2 00:45:35 UTC 2007

> TCB_STARTUP && TCB_BPTSET can IMO happen only happen for the newly
> forked/cloned child and its first signal should be always SIGSTOP.
> I hope I did not miss any other case.

It's true that TCB_BPTSET|TCB_STARTUP happens only for a new child when the
parent was traced with internal_{clone,fork}.  It is not true that the
child's first signal will always be SIGSTOP.  In this case as any other,
some other signal could have come along and be seen first.

> The removed FIXVFORK call may be wrong but I am not sure if it is still valid.
I have no idea about the SUNOS4 code paths.

> > Finally, cleanup (i.e. detach) has check for TCB_STARTUP and know it should
> > not add another SIGSTOP, but must do wait4's and until it can swallow the
> > expected SIGSTOP (which it already does).
> It was interesting to me this exception is really needed there.
> Without the exception the inferior process get stopped, with strace-of-strace:
> ptrace(PTRACE_DETACH, 16656, 0x1, SIG_0) = -1 ESRCH (No such process)
> kill(16656, SIG_0)                      = 0
> kill(16656, SIGSTOP)                    = 0
> wait4(16656, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGSTOP}], __WALL, NULL) = 16656
> --- SIGCHLD (Child exited) @ 0 (0) ---
> ptrace(PTRACE_DETACH, 16656, 0x1, SIG_0) = 0
> In the kill(..., SIGSTOP) moment the SIGSTOP was still pending, it got
> stacked there twice, though.

I'm not entirely following what you are saying here.  But the situation
this is.  Signals like SIGSTOP do not queue, only one SIGSTOP is in the
pending set at a time.  So, when a SIGSTOP is already pending, another kill
does not do anything more.  But, you never know when the thread might
actually wake up and deliver the SIGSTOP from the pending set.  If it had
already pulled out the pending SIGSTOP, but not finished stopping, or your
wait4 call hadn't finished waking up and returning yet, when you did the
kill, then the second SIGSTOP will go into the pending set and be delivered
later (like after you detach).

> Attached `slowcall.c' for easier testing of attachment to a long lasting single
> syscall.  I miss some strace testsuite, I saw in ChangeLog an entry (?):
> 	* test/clone.c: improve our testcase a bit

If you look in sourceforge cvs, there are a few things in test/.  
I never distributed them when I took over strace and automakified it.
They don't seem useful to me.  It would certainly be good to have a proper
test suite.  I just haven't had the time or interest to work on one.

> All your comments should be processed, your mail has been converted to the
> attached patch.

I didn't check that the broken-out functions' text didn't change from what
was in main before.  But otherwise it looks fine modulo nits.

Your log entry has some format typos (missing :s).  Don't put my name in
the log entry header, I didn't write the code.  Mention advice if you want to.
Is there a Fedora bz# that should be mentioned in this log entry?


More information about the Strace-devel mailing list