[BUG] strace hangs when using -f on CLONE_VFORK

Heiko Carstens Heiko.Carstens at de.ibm.com
Mon Jan 17 03:09:11 UTC 2005


Hi all,

strace hangs if used with the follow-fork option and if the traced process 
does a clone()
system call with CLONE_VFORK flag. Reason for this is a kind of deadlock:

The kernel suspends the parent (wait_for_completion() in do_fork()) until 
the child finally calls
mm_release(). A call to mm_release() will only happen if the child will 
call the execve() or
exit() systemcall.
Unfortunately this will never happen if the tasks are traced with the 
follow-fork option as it's
already described in the trace() function in strace.c:

/* This is needed to go with the CLONE_PTRACE
changes in process.c/util.c: we might see
the child's initial trap before we see the
parent return from the clone syscall.
Leave the child suspended until the parent
returns from its system call.  Only then
will we have the association of parent and
child so that we know how to do clearbpt
in the child.  */

Since strace waits for the parent to do something but the parent waits for 
the child to exit()
or execve() we will inevitably come to a deadlock situtation.

While removing the TCB_SUSPENDED flag for the child in this case will fix 
this issue, I'm
not sure if this would break other things.

Any ideas how to fix this?

Thanks,
Heiko





More information about the Strace-devel mailing list