Fix vfork-by-clone tracing (on ia64)

Dmitry V. Levin ldv at altlinux.org
Mon Jun 30 22:45:43 UTC 2008


On Mon, Jun 30, 2008 at 03:25:58PM +0200, Jan Kratochvil wrote:
[...]
> this testcase hangs on ia64:
> 
> $ echo 'int main () { return vfork (); }' >vfork.c; gcc -o vfork vfork.c; strace -f ./vfork
> execve("./vfork", ["./vfork"], [/* 41 vars */]) = 1
> ...
> clone(Process 2929 attached (waiting for parent)

Aside: the sys_clone parser is poor, it does not show all available
syscall parameters when entering syscall.

> Fix tested on RHEL-5 kernel-2.6.18-94.el5.ia64.  Older kernels (such as
> kernel-2.6.18-53.el5.ia64) do not hang as they have a bug causing strace not
> tracing the children (as strace is unable to force CLONE_PTRACE there).
> Sorry for no ia64 vanilla kernels testing.

I still do not fully understand why strace may hang in this case.

> @@ -1524,12 +1527,17 @@ struct tcb *tcp;
>  #ifdef SYS_clone2
>  	case SYS_clone2:
>  #endif
> -		if ((tcp->u_arg[arg0_index] & CLONE_PTRACE) == 0
> -		    && (arg_setup (tcp, &state) < 0
> -			|| set_arg0 (tcp, &state,
> -				     tcp->u_arg[arg0_index] | CLONE_PTRACE) < 0
> -			|| arg_finish_change (tcp, &state) < 0))
> -			return -1;
> +		/* ia64 calls directly `clone (CLONE_VFORK)' contrary to x86
> +		   SYS_vfork above.  Even on x86 we turn the VFORK semantics
> +		   into plain FORK - each application must not depend on the
> +		   VFORK specifics according to POSIX.  We would hang waiting
> +		   for the parent resume otherwise.  */
> +		if ((arg_setup (tcp, &state) < 0
> +		    || set_arg0 (tcp, &state,
> +				 (tcp->u_arg[arg0_index] | CLONE_PTRACE)
> +				 & ~CLONE_VFORK) < 0
> +		    || arg_finish_change (tcp, &state) < 0))
> +		    return -1;

We already change vfork() to fork() in followvfork mode, so changing
clone() this way is probably acceptable here, too.  I'm not sure, though.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20080701/dde9e2c1/attachment.bin>


More information about the Strace-devel mailing list