dlsym with RTLD_NEXT and unknown symbol causes segfault on ppc

Kevin B. Hendricks kevin.hendricks@sympatico.ca
Fri Sep 15 09:15:00 GMT 2000


Hi Franz,

When the jdk under green threads fails instantly with a segfault under glibc 2.2
cvs because whenever dlsym (using RTLD_NEXT) is used to lookup a nonexistent
symbol it segfaults.

I have no idea if this is a ppc specific problem or not.

Here is a stripped down piece of test code:

[root@khendricksmac jdk]# gcc -o bug1 -D_GNU_SOURCE -ldl -lc bug1.c
[root@khendricksmac jdk]# ./bug1
Segmentation fault
[root@khendricksmac jdk]# 


[root@khendricksmac jdk]# cat bug1.c

#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <dlfcn.h>

typedef int (*sysfunc_t)();


int 
main(int argc, char** argv)
{
    char *sym="_filbuf";
    sysfunc_t addr;
    addr = (sysfunc_t) dlsym(RTLD_NEXT,sym);
    fprintf(stdout, "All is well\n");
    fflush(stdout);
    exit(0);
}

Program received signal SIGSEGV, Segmentation fault.
0x30009ebc in _dl_lookup_symbol_skip () from /lib/ld.so.1
(gdb) bt
#0  0x30009ebc in _dl_lookup_symbol_skip () from /lib/ld.so.1
#1  0xff9fa78 in _dl_sym () from /lib/libc.so.6
#2  0xffde4e0 in dlsym_doit () from /lib/libdl.so.2
#3  0x3000e6ec in _dl_catch_error () from /lib/ld.so.1
#4  0xffde898 in _dlerror_run () from /lib/libdl.so.2
#5  0xffde53c in dlsym () from /lib/libdl.so.2
#6  0x10000580 in main ()
#7  0xfebe7c8 in __libc_start_main () from /lib/libc.so.6
#8  0x0 in ?? ()
(gdb)


More information about the Libc-alpha mailing list