strace bug for clone()

Michael Holzheu HOLZHEU at de.ibm.com
Tue Mar 2 00:53:02 UTC 2004




Hi Roland,

Thanks, but you missed one line! Here is the patch to fix this:

--- util.c.orig 2004-03-01 22:29:22.000000000 +0100
+++ util.c      2004-03-02 09:33:12.165122109 +0100
@@ -1384,7 +1384,7 @@
 #ifdef SYS_clone2
        case SYS_clone2:
 #endif
-               if ((tcp->u_arg[0] & CLONE_PTRACE) == 0
+               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


Here is a testprogram, which failes with strace -f (with 4.5.2):

#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <sched.h>
#include <signal.h>

char stack[10000];

int childfn(void* arg)
{
        printf("CHILD\n");
        return 0;
}

int main(void)
{
        pid_t child;
        int status,rc;
        child = clone(&childfn,stack+sizeof(stack)
,CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD ,NULL);
        rc = waitpid(child,&status,0);
        printf("parent rc: %i\n",rc);
        return 0;
}


>> strace -f ./testme
...
munmap(0x40018000, 24350)               = 0
clone(CHILD
Process 939 attached
child_stack=0x403fec,
flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0) =
939
[pid   938] --- SIGCHLD (Child exited) @ 0 (0) ---
[pid   938] wait4(939, Process 938 suspended

>>>> strace hangs here


Regards

       Michael

------------------------------------------------------------------------
Linux for E-Server Development
Phone: +49-7031-16-2360,  Bld 71032-03-U09
Email: holzheu at de.ibm.com



|---------+---------------------------------------->
|         |           Roland McGrath               |
|         |           <roland at redhat.com>          |
|         |           Sent by:                     |
|         |           strace-devel-admin at lists.sour|
|         |           ceforge.net                  |
|         |                                        |
|         |                                        |
|         |           01.03.2004 22:03             |
|         |                                        |
|---------+---------------------------------------->
  >-----------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                             |
  |       To:       Michael Holzheu/Germany/IBM at IBMDE                                                                           |
  |       cc:       strace-devel at lists.sourceforge.net                                                                          |
  |       Subject:  Re: strace bug for clone()                                                                                  |
  |                                                                                                                             |
  |                                                                                                                             |
  >-----------------------------------------------------------------------------------------------------------------------------|



Thanks for the report and patch.  I've put in a slightly different fix with
the same effect.


Thanks,
Roland


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Strace-devel mailing list
Strace-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel







More information about the Strace-devel mailing list