This is the mail archive of the
libc-hacker@cygnus.com
mailing list for the glibc project.
dlopen uniqueness bug
- To: libc-hacker@cygnus.com
- Subject: dlopen uniqueness bug
- From: Richard Henderson <rth@cygnus.com>
- Date: Wed, 17 Feb 1999 22:38:51 -0800
- Reply-To: rth@twiddle.net
Reported by Mike Shaver (shaver@netscape.com)
Repeat as
gcc -shared -o /tmp/dll.so dll.c
gcc -o /tmp/main main.c
cd /tmp
./main
We are only checking uniqueness of filename, not of file. We should
be using stat to make sure the so isn't already loaded. Solaris
gets this right.
r~
#include <stdio.h>
#include <dlfcn.h>
int main(int argc, char** argv)
{
void *a, *b, *c, *d;
/* Load the same dll several times */
a = dlopen("./dll.so", RTLD_NOW);
b = dlopen("./../tmp/dll.so", RTLD_NOW);
c = dlopen("/tmp/dll.so", RTLD_NOW);
d = dlopen("/tmp/../tmp/dll.so", RTLD_NOW);
if (a == b && b == c && c == d)
printf("ok\n");
else
printf("a = %p, b = %p, c = %p, d = %p\n", a, b, c, d);
}
#include <stdio.h>
void foo(void)
{
printf("foo in dll called\n");
}