bug-glibc
[Top][All Lists]
Advanced

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

New dynamic loader (was Re: 2.1.96 & apache mod_setenv)


From: Petr Vandrovec
Subject: New dynamic loader (was Re: 2.1.96 & apache mod_setenv)
Date: Fri, 10 Nov 2000 09:08:45 MET-1

On  1 Nov 00 at 21:19, address@hidden wrote:
> Hi,
>   does anybody around have some idea why code which worked with all
> previous glibc releases (2.1.3, 2.1.94, 2.1.95) fails with 2.1.96 
> in strange ways? I tried to load efence to no avail, but results are 
> still same: when loaded with 2.1.96 libc, apache dies. When loaded 
> with 2.1.95 libc by 2.1.96 loader, it exits with 'error 1', probably 
> because of some problem with relocations (?!). Only loading by 2.1.95 
> loader with 2.1.95 libc works.

Hi,
  on Nov 1st, I posted here, that with glibc 2.1.96 (and now 2.1.97)
my Apache does not work, and other programs get spurious sigsegv.
After looking up and down, I wrote following test program. If
I do

./x /usr/lib/libpthread.so /usr/lib/libnss_dns.so

program gets sigsegv in dlclose() when closing nss_dns module. If
I run it as

LD_PRELOAD=/lib/libc-2.1.95.so /lib/ld-2.1.95.so ./x /usr/lib/libpthread.so 
/usr/lib/libnss_dns.so

it works :-( Failure modes are sometime not that simple. For example
mod_auth_kerb (kerberos authentication module) can be correctly
unloaded if I load libsasl manually before all other libraries
autoloaded by mod_auth_kerb. If I left libsasl loading on autoloader,
mod_auth_kerb dies on unload...

  I again repeat, that with old libc & ld it works fine, so probably
changes which went into dynamic loader for 2.1.96 broke something :-(
Maybe it has something to do with weak symbols... maybe not. I was not
able to reproduce it with simple libraries.

  And btw, if I do
  
./x /usr/lib/libpthread.so /usr/lib/libresolv.so /usr/lib/libnss_dns.so,

it works with both 2.1.95 and 2.1.96 (and 2.1.97). So it can be bug
in RTLD_LAZY? If I left libresolv loading on autoloader, it dies.
                                    Thanks,
                                            Petr Vandrovec
                                            address@hidden
                                            

vana:/mnt/ggg/r# gdb x
GNU gdb 5.0
Copyright 2000 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) set args /usr/lib/libpthread.so /usr/lib/libnss_dns.so
(gdb) run
Starting program: /mnt/ggg/r/x /usr/lib/libpthread.so /usr/lib/libnss_dns.so
(no debugging symbols found)...(no debugging symbols found)...(no debugging 
symbols found)...(no debugging symbols found)...
[New Thread 1024 (LWP 8347)]
/usr/lib/libpthread.so loaded, no symbol requested
/usr/lib/libnss_dns.so loaded, no symbol requested
(no debugging symbols found)...(no debugging symbols found)...
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 8347)]
0x400950bd in free () from /lib/libc.so.6
(gdb) bt
#0  0x400950bd in free () from /lib/libc.so.6
#1  0x4011128a in _dl_close () from /lib/libc.so.6
#2  0x400233bb in dlopen () from /lib/libdl.so.2
#3  0x4000c8f2 in _dl_catch_error () from /lib/ld-linux.so.2
#4  0x4002373f in dlerror () from /lib/libdl.so.2
#5  0x400233e1 in dlclose () from /lib/libdl.so.2
#6  0x80485b5 in freeall ()
#7  0x8048636 in main ()
#8  0x40041bdc in __libc_start_main () from /lib/libc.so.6
(gdb)

-- x.c --

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

void *arra[256];
const char* nam[256];

int j = 0;

int ldlib(const char* path) {
    void* lb;
    void* q;
    
    lb = dlopen(path, RTLD_GLOBAL | RTLD_NOW);
    if (!lb) {
        printf("Cannot load %s: %s\n", path, dlerror());
        return 0;
    }
    nam[j] = path;
    arra[j++] = lb;
    printf("%s loaded, no symbol requested\n", path);
    return 1;
}

void freeall(void) {
    while (j) {
        if (dlclose(arra[--j])) {
            printf("Cannot close %s: %s\n", nam[j], dlerror());
        }
    }
}
    
int main(int argc, char* argv[]) {
    int i;
    
    for (i = 1; i < argc; i++) {
        ldlib(argv[i]);
    }
    freeall();

    printf("OK\n");
    return 0;
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]