dlopen() hangs - Linux

This is a discussion on dlopen() hangs - Linux ; Hi Why does my program get stuck in dlopen(). void x() { lib_handle = dlopen("lib.so", RTLD_LAZY); fn_handle = dlsym(); call fn_handle dlclose(); } main() { x(); } after calling x() about 100 times my program gets stuck in dlsym() and ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: dlopen() hangs

  1. dlopen() hangs

    Hi

    Why does my program get stuck in dlopen().

    void x()
    {
    lib_handle = dlopen("lib.so", RTLD_LAZY);
    fn_handle = dlsym();
    call fn_handle
    dlclose();
    }

    main()
    {
    x();
    }

    after calling x() about 100 times my program gets stuck in dlsym() and
    when I send SIGKILL I get this backtrace in core:

    #0 0x3000b208 in _dl_relocate_object () from /lib/ld.so.1
    (gdb) bt
    #0 0x3000b208 in _dl_relocate_object () from /lib/ld.so.1
    #1 0x0fdb3d1c in getutmpx () from /lib/libc.so.6
    #2 0x3000cf44 in _dl_catch_error () from /lib/ld.so.1
    #3 0x0fdb3f38 in _dl_open () from /lib/libc.so.6
    #4 0x0fc520f8 in ?? () from /lib/libdl.so.2
    #5 0x3000cf44 in _dl_catch_error () from /lib/ld.so.1
    #6 0x0fc52544 in dlerror () from /lib/libdl.so.2
    #7 0x0fc5214c in dlopen () from /lib/libdl.so.2
    #8 0x0fc5214c in dlopen () from /lib/libdl.so.2
    #9 0x0fc5214c in dlopen () from /lib/libdl.so.2
    #10 0x0fc5214c in dlopen () from /lib/libdl.so.2
    #11 0x0fc5214c in dlopen () from /lib/libdl.so.2
    #12 0x0fc5214c in dlopen () from /lib/libdl.so.2
    #13 0x0fc5214c in dlopen () from /lib/libdl.so.2
    #14 0x0fc5214c in dlopen () from /lib/libdl.so.2
    #15 0x0fc5214c in dlopen () from /lib/libdl.so.2
    warning: Previous frame inner to this frame (corrupt stack?)
    (gdb)

    can someone tell me whats going on?

    thanks


  2. Re: dlopen() hangs

    "berkeleydb_user" writes:

    > Why does my program get stuck in dlopen().
    >
    > void x()
    > {
    > lib_handle = dlopen("lib.so", RTLD_LAZY);
    > fn_handle = dlsym();
    > call fn_handle
    > dlclose();
    > }


    This couldn't possibly compile. Post a *complete* test case, as
    well as versions of glibc and binutils.

    You may also wish to read this:
    http://www.catb.org/~esr/faqs/smart-questions.html

    > after calling x() about 100 times my program gets stuck in dlsym() and
    > when I send SIGKILL I get this backtrace in core:
    >
    > #0 0x3000b208 in _dl_relocate_object () from /lib/ld.so.1
    > (gdb) bt
    > #0 0x3000b208 in _dl_relocate_object () from /lib/ld.so.1
    > #1 0x0fdb3d1c in getutmpx () from /lib/libc.so.6
    > #2 0x3000cf44 in _dl_catch_error () from /lib/ld.so.1
    > #3 0x0fdb3f38 in _dl_open () from /lib/libc.so.6
    > #4 0x0fc520f8 in ?? () from /lib/libdl.so.2
    > #5 0x3000cf44 in _dl_catch_error () from /lib/ld.so.1
    > #6 0x0fc52544 in dlerror () from /lib/libdl.so.2
    > #7 0x0fc5214c in dlopen () from /lib/libdl.so.2
    > #8 0x0fc5214c in dlopen () from /lib/libdl.so.2
    > #9 0x0fc5214c in dlopen () from /lib/libdl.so.2
    > #10 0x0fc5214c in dlopen () from /lib/libdl.so.2
    > #11 0x0fc5214c in dlopen () from /lib/libdl.so.2
    > #12 0x0fc5214c in dlopen () from /lib/libdl.so.2
    > #13 0x0fc5214c in dlopen () from /lib/libdl.so.2
    > #14 0x0fc5214c in dlopen () from /lib/libdl.so.2
    > #15 0x0fc5214c in dlopen () from /lib/libdl.so.2
    > warning: Previous frame inner to this frame (corrupt stack?)
    > (gdb)
    >
    > can someone tell me whats going on?


    Somehow you managed to get dlopen() into (infinite?) recursion.
    Do you call dlopen() from within lib.so initializer?

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  3. Re: dlopen() hangs


    berkeleydb_user wrote:
    > Hi
    >
    > Why does my program get stuck in dlopen().


    Because you have a function called from 'dlopen' that calls 'dlopen'.

    DS


+ Reply to Thread