[lkml]   [1998]   [Sep]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Subjectclone() and dl library incompatible?

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

    Here are relevant versions:

    Linux 2.0.34 #1 Fri May 8 16:05:57 EDT 1998 i586 unknown

    Here's how to reproduce the problem:

    1. Make a file called ctest.c, containing:

    #include <stdio.h>
    #include <stdlib.h>
    #include <schedbits.h>

    foo( void *arg )
    fprintf( stderr, "in foo, pid = %d\n", getpid() );
    sleep( 2 );

    void *stk = malloc( 1024 * 1024 );

    clone( foo, stk, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND, 0 );

    fprintf( stderr, "in main, pid = %d\n", getpid() );
    sleep( 2 );

    2. Make a file called csub.c, containing:

    #include <dlfcn.h>

    int call_sub()
    dlopen( "somefile", RTLD_LAZY );
    return 0;

    3. Make sure that LD_LIBRARY_PATH contains the current directory

    4. Compile, link, and run to show that it there is no problem with clone()
    when the dl library is not involved:

    cc -c csub.c
    ld -shared -o csub.o
    cc -o ctest ctest.c -L. -lcsub

    (You will see:
    in main, pid = xxx
    in foo, pid = xxx+1)

    5. recompile, relink, and rerun to show that clone() fails when the dl
    library is involved:

    cc -c -DWILL_BREAK_CLONE csub.c
    ld -shared -o csub.o -ldl

    (You will see:
    in main, pid = xxx) - the cloned thread will have died before running foo...

    I would appreciate any information that would help me get around this...



    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:44    [W:0.020 / U:27.820 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site