- To: bugs@gnu.org
- Subject: libc/753: dlopen fails randomly if used in a threaded applicaton
- From: hakan@hobbe.LUB.lu.se
- Date: Sun, 23 Aug 1998 18:20:46 +0200
- Resent-Cc: gnats-admin@gnu.org
- Resent-Reply-To: bugs@gnu.org, hakan@hobbe.LUB.lu.se
- Resent-To: libc-gnats@gnu.org
>Number: 753
>Category: libc
>Synopsis: dlopen fails with and "undefined symbol" error
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: libc-gnats
>State: open
>Class: sw-bug
>Submitter-Id: unknown
>Arrival-Date: Sun Aug 23 12:30:01 EDT 1998
>Last-Modified:
>Originator: Hakan Ardo
>Organization:
---------------------------------------------------------------
Name: Hakan Ardo
E-Mail: hakan@debian.org
WWW: http://www.ub2.lu.se/~hakan/sig.html
Public Key: Try "finger hakan@master.debian.org"
Fingerprint: E9 81 FD 90 53 5C E9 3E 3D ED 57 15 1B 7E 29 F3
Interests: WWW, Programming, 3D graphics
Thought for the day: As long as one understands, the
spelling does not matter :-)
---------------------------------------------------------------
>
>Release: libc-2.0.7
>Environment:
Host type: i586-pc-linux-gnu
System: Linux hobbe 2.0.35 #1 Sat Aug 1 14:23:16 CEST 1998 i586 unknown
Architecture: i586
Libs: libpthread-0.7.so
gcc version egcs-2.90.29 980515 (egcs-1.0.3 release)
gcc version 2.7.2.3
(Same result with both compiles here)
GNU ld version 2.9.1 (with BFD 2.9.1)
Addons: crypt linuxthreads localedata
Build CFLAGS: -g -O2
Build CC: gcc -B$(common-objpfx)
Build shared: yes
Build profile: yes
Build omitfp: no
Stdio: libio
>Description:
I'm working on the mnemonic project and we're having trouble getting
dlopen to work together with threads and libc6. There seems to be no
problems using libc5 though. Below is a little test proggy that
starts one background thread and then tries to dlopen argv[1], which
randomly fails on symbols that are located in the .so file beeing loaded:
hakan@hobbe [41] % ./dlbug /usr/X11/lib/libXm.so.0
A!
dlerror: /usr/X11R6/lib/libX11.so.6: undefined symbol: _XInitDisplayLock_fn
hakan@hobbe [42] % ./dlbug /usr/X11/lib/libXm.so.0
A!
dlopen ok
hakan@hobbe [42] % ./dlbug /usr/X11/lib/libXm.so.0
A!
dlerror: /usr/X11R6/lib/libXt.so.6: undefined symbol: _XtInherit
hakan@hobbe [42] % ./dlbug /usr/X11/lib/libXm.so.0
A!
hakan@hobbe [42] % ./dlbug /usr/X11/lib/libXm.so.0
A!
dlerror: /usr/X11/lib/libXm.so.0: undefined symbol: _XtInherit
The problem shows best on libs that is linked to several other libs,
such as libXm.so, presumable because that gives the other thread more
time to interrupt the process.
>How-To-Repeat:
This proggy was compiled with:
gcc -o dlbug -rdynamic dlbug.c -ldl -lpthread
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
#include "pthread.h"
#include <dlfcn.h>
void * a(void * arg) {
while (1) {
fprintf(stderr,"A!\n");
sleep(1);
}
}
int main(int argc, char **argv)
{
int retcode;
pthread_t th_a;
void * retval;
void *h;
char *error;
retcode = pthread_create(&th_a, NULL, a, NULL);
if (retcode != 0) fprintf(stderr, "create a failed %d\n", retcode);
h=dlopen(argv[1],RTLD_NOW|RTLD_GLOBAL);
if(!h) {
if ((error = dlerror()) != NULL) {
fprintf(stderr,"dlerror: %s\n",error);
}
} else {
fprintf(stderr,"dlopen ok\n");
dlclose(h);
}
return 0;
}
>Fix:
>Audit-Trail:
>Unformatted: