[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#67296: recursive dlopen with RTLD_GLOBAL segfaults



Package: libc6
Version: 2.1.3-10
Severity: normal

This appears to be an upstream bug, see the following two test programs:

------ client.c ----

#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>

int main(int argc, char *argv[])
{
   void *Hand = dlopen(argv[1],RTLD_NOW | RTLD_GLOBAL);
   
   printf("Hand = %p\n",Hand);
   
   printf("Sym = %p\n",dlsym(0,"glBegin"));
   printf("Sym = %p\n",dlsym(Hand,"glBegin"));

   return 0;
}

----- lib.c ----

#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>

void _init()
{
   struct link_map *GLLib;

   if ((GLLib = dlopen("/usr/lib/libGL.so.1.0",RTLD_LAZY | RTLD_GLOBAL)) == 0)
   {
      fprintf(stderr,"Unable to open GL lib '%s'\n",
	      "/usr/lib/libGL.so.1.0");
      return;
   }
}

----- end

Compiling and running results in a seg fault:

taupe{jgg}/tmp/bug#gcc -Wall client.c  -ldl -o client
taupe{jgg}/tmp/bug#gcc -nostdlib -shared -o lib.so -Wall -ldl lib.c

taupe{jgg}/tmp/bug#gdb ./client 
GNU gdb 19990928
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(no debugging symbols found)...
(gdb) run ./lib.so
Starting program: /tmp/bug/./client ./lib.so
(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...
Program received signal SIGSEGV, Segmentation fault.
0x400e3a20 in getutmpx () from /lib/libc.so.6
(gdb) bt
#0  0x400e3a20 in getutmpx () from /lib/libc.so.6
#1  0x4000a135 in _dl_catch_error () from /lib/ld-linux.so.2
#2  0x400e3b10 in _dl_open () from /lib/libc.so.6
#3  0x4001a34e in _init () from /lib/libdl.so.2
#4  0x4000a135 in _dl_catch_error () from /lib/ld-linux.so.2
#5  0x4001a93e in dlerror () from /lib/libdl.so.2
#6  0x4001a38b in dlopen () from /lib/libdl.so.2
#7  0x80484cc in main ()
#8  0x40035a42 in __libc_start_main () from /lib/libc.so.6
(gdb) 

Oddly removing the RTLD_GLOBAL from *either* dlopen allows it to work as
expected.

-- System Information
Debian Release: 2.2
Architecture: i386
Kernel: Linux taupe 2.2.15pre20 #1 Wed May 3 13:05:19 MDT 2000 i686

Versions of packages libc6 depends on:
ii  ldso                          1.9.11-9   The Linux dynamic linker, library 




Reply to: