Re: clone() and dl library incompatible?

Ulrich Drepper (drepper@cygnus.com)
24 Sep 1998 17:56:41 -0700


Steve Jacobson <sdj@franz.com> writes:

> Following is a simple example that works when the dl library isn't involved
> at link time, but fails when it is.

This has nothing to do with dl, it's just bad fortune that the crash
happens only in this situation.

> void *stk = malloc( 1024 * 1024 );
>
> clone( foo, stk, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND, 0 );

Clone expects the *end* of the stack as the argument. I.e.,

clone (foo, stk + 1024 * 1024, ...)

But you shouldn't use clone() in the first place. The libc will not
be thread safe unless you link against libpthread (or use define the
needed magic in your programs as well).

-- 
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/