[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
dlopen and shared objects using pthreads.
From: |
Adam Dickmeiss |
Subject: |
dlopen and shared objects using pthreads. |
Date: |
Wed, 28 Mar 2001 09:47:57 +0200 |
User-agent: |
Mutt/1.2.5i |
Hi,
it is a well known rule for Apache admins that if they plan
to use loadable modules that uses pthreads they have to recompile
Apache and add the flag -lpthread for the Linker in order to
prevent a crash.
I think the bug is related to glibc, so I decided to spent some
time creating a small test case that illustrates this. See the
Makefile and the two C sources below.
[snip] sub.c:
int sub(void) { return 1; }
[snip] main.c:
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
int main(int argc, char **argv)
{
int r;
void *h;
h = dlopen ("./sub.so", RTLD_NOW|RTLD_GLOBAL);
if (!h)
{
printf ("dlopen failed\n");
exit (1);
}
gethostbyname("slashdot.org");
dlclose (h);
exit (0);
}
[snip] Makefile
all: sub.so main-wt main-wot
sub.so: sub.c
gcc -D_REENTRANT -shared sub.c -o sub.so -lpthread
main-wt: main.c
gcc main.c -o main-wt -ldl -lpthread
main-wot: main.c
gcc main.c -o main-wot -ldl
clean:
rm -f main-wt main-wot sub.so core
[end]
The program main-wt works. The other main-wot dies with a SEGV
in dlclose or gethostbyname.
I see this behaviour on a Debian GNU/Linux using ldd version 1.9.11 and
on Redhat Fisher using ldd 1.2.1.
Cheers,
Adam
--
Adam Dickmeiss mailto:address@hidden http://www.indexdata.dk
Index Data T: +45 33410100 Mob.: 212 212 66
- dlopen and shared objects using pthreads.,
Adam Dickmeiss <=