This is the mail archive of the
libc-hacker@cygnus.com
mailing list for the glibc project.
Bug or feature in dlsym()? Makes Mozilla/NGLayout crash at startup.
- To: libc-alpha@cygnus.com
- Subject: Bug or feature in dlsym()? Makes Mozilla/NGLayout crash at startup.
- From: Stephane Rehel <rehel@worldnet.fr>
- Date: Wed, 20 Jan 1999 00:50:36 +0100
>Submitter-Id: net
>Originator: kepler
>Organization:
Stephane Rehel.
>
>Confidential: no
>Synopsis: two dlsym() on two different libraries with same function name return the same pointer
>Severity: critial
>Priority: high
>Category: libc
>Class: sw-bug
>Release: libc-2.0.110
>Environment:
Host type: i686-pc-linux-gnu
System: Linux floups 2.1.132 #5 Tue Dec 29 01:20:00 GMT+0100 1998 i686 unknown
Architecture: i686
Addons: linuxthreads crypt
Build CC: gcc
Compiler version: 2.8.1
Kernel headers: 2.1.132
Symbol versioning: yes
Build static: yes
Build shared: yes
Build pic-default: no
Build profile: yes
Build omitfp: no
Build bounded: no
Build static-nss: no
Stdio: libio
>Description:
First i would like to thank you very much for writing glibc.
It makes Linux so faast!
Let lib1.so and lib2.so be two shared libraries.
They both define and implement a function NSGetFactory().
I generate a program that dlopen() these two libs, and that does
a dlsym() for each lib on order to find the two entry points of
these functions.
The program is dynamically linked with these libraries.
The fact is that the two dlsym() return the same pointer.
I really don't know if this is a bug or a feature. I have found
this bug while trying to run Mozilla/NGLayout. Apparently people
have no difficulty to run it with glibc 2.0
>How-To-Repeat:
I tried to isolate the bug. libxpcom and libwidgetgtk are two
library names used by Mozilla.
go.c is the main program.
show_the_bug builds the two libraries and the program, and
runs the program.
[--go.c (begin)------------------------------------------cut-here------]
#include <stdio.h>
#include <dlfcn.h>
int main()
{
void *h1, *h2;
void (*f1)(), (*f2)();
h1= dlopen("libmy_xpcom.so",RTLD_LAZY);
if(!h1) printf("dlopen1: %s\n",dlerror());
h2= dlopen("libmy_widgetgtk.so",RTLD_LAZY);
if(!h2) printf("dlopen2: %s\n",dlerror());
f1= dlsym(h1,"NSGetFactory");
if(!f1) printf("dlsym1: %s\n",dlerror());
f2= dlsym(h2,"NSGetFactory");
if(!f2) printf("dlsym2: %s\n",dlerror());
printf("lib1; h=%p f=%p\n", h1, f1 );
printf("lib2; h=%p f=%p\n", h2, f2 );
(*f1)();
(*f2)();
return 0;
}
[--go.c (end)--------------------------------------------cut-here------]
[--show_the_bug (begin)----------------------------------cut-here------]
#!/bin/sh -xe
echo 'void NSGetFactory() { printf("xpcom\n"); }' > my_xpcom.c
gcc -shared -o libmy_xpcom.so my_xpcom.c
echo 'void NSGetFactory() { printf("widgetgtk\n"); }' > my_widgetgtk.c
gcc -shared -o libmy_widgetgtk.so my_widgetgtk.c
gcc -rdynamic -o go go.c -L. -lmy_widgetgtk -lmy_xpcom -ldl
ldd ./go
export LD_LIBRARY_PATH=.
./go
[--show_the_bug (end)------------------------------------cut-here------]
[--OUTPUT-(begin)------------------------------------------------------]
webby:~/glibc-test$ ./show_the_bug
+ echo 'void NSGetFactory() { printf("xpcom\n"); }'
+ gcc -shared -o libmy_xpcom.so my_xpcom.c
+ echo 'void NSGetFactory() { printf("widgetgtk\n"); }'
+ gcc -shared -o libmy_widgetgtk.so my_widgetgtk.c
+ gcc -rdynamic -o go go.c -L. -lmy_widgetgtk -lmy_xpcom -ldl
+ export LD_LIBRARY_PATH=.
+ LD_LIBRARY_PATH=.
+ ldd ./go
libmy_widgetgtk.so => ./libmy_widgetgtk.so (0x40015000)
libmy_xpcom.so => ./libmy_xpcom.so (0x40019000)
libdl.so.2 => /lib/libdl.so.2 (0x4001f000)
libc.so.6 => /lib/libc.so.6 (0x40022000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
+ ./go
lib1; h=0x40018000 f=0x400156a0
lib2; h=0x40014b40 f=0x400156a0
widgetgtk
widgetgtk
[--OUTPUT-(end)--------------------------------------------------------]
>Fix:
I don't know.
Thanks,
Stephane Rehel.