Re: clone testcases in LTP

From: Ian Wienand <ianw_at_gelato.unsw.edu.au>
Date: 2003-07-11 10:35:12
On Wed, Jul 09, 2003 at 03:17:42PM -0700, David Mosberger wrote:
>   Nathan> Could someone in the Linux ia64 community look at the clone
>   Nathan> system call tests that the LTP has under
> The only difference between clone() and clone2() is the explicit
> stack-size argument.

And that you pass the bottom of the stack, not the top?  Also, are
there explicit alignment requirements?  I thought it needed to be
aligned to page size (or maybe it was 16 bytes).  And should the stack
size be at a minimum ~8K, to allow enough room for register stack?

I have noticed a problem from the LTP tests.  Either I'm doing
something wrong (likely related to my assumptions above) or there is
something wrong.  See clone2.c below.  gdb doesn't catch the new
thread, but if you watch with strace you see the new thread gets a
SEGV somewhere in the dynamic loader on exit, and doesn't set the
return value properly.  The LTP tests pick this up.

This doesn't happen if thread() explicitly calls _exit(), rather than
just return (which should just call _exit).  This makes me think it's
something to do with __clone2 in in glibc.  It looks OK to me by
inspection, but unfortunately I am going away for some weeks today so
can't look into this much further.

Am I misunderstanding something?  Should my example work?

(I attached what I did anyway.  BTW the files have DOS line feeds,
which seems wrong)

-i
ianw@gelato.unsw.edu.au
http://www.gelato.unsw.edu.au

--- clone2.c ---
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sched.h>
#include <sys/wait.h>
#include <sys/types.h>
 
#define MB (1024*1024)
 
int thread(void *nothing)
{
        printf("HELLO\n");
        return 100;
}
 
int main(void)
{
 
    int ret, status;
 
    char *child_stack_base;
    child_stack_base = valloc( MB );
    printf("I see the stack @ %lx\n", child_stack_base);
 
    ret = __clone2(&thread, child_stack_base , MB, SIGCHLD);
 
    wait(&status);
    printf("Child exited (%d)\n", WEXITSTATUS(status));
     
    exit(0);
 
}
-
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Received on Thu Jul 10 20:35:35 2003

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:16 EST