This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bugreport: dlopen in threaded application



We've received the appended bug report about problems with dlopen in
threaded applications.  Using the supplied test program, I can
reproduce the problem with glibc 2.1 and glibc 2.0.7 when calling the
program several times.

Is this a problem of dlopen being not thread safe?  Is there a way to 
fix this?

Andreas
-- 
 Andreas Jaeger   aj@arthur.rhein-neckar.de    jaeger@informatik.uni-kl.de
  for pgp-key finger ajaeger@alma.student.uni-kl.de



>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:




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]