This is the mail archive of the libc-alpha@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]

[paul@parasoft.com] libc/1188: dlsym(RTLD_NEXT ...) returns non-default symbol



Hi all,

Paul send us the appended bug report.  Could anybody look into it,
please?

Thanks,
Andreas



Topics:
   libc/1188: dlsym(RTLD_NEXT ...) returns non-default symbol (when symbol versioning is used)


----------------------------------------------------------------------

Date: Tue, 29 Jun 1999 17:12:00 -0400
From: paul@parasoft.com
To: bugs@gnu.org
Subject: libc/1188: dlsym(RTLD_NEXT ...) returns non-default symbol (when symbol versioning is used)
Message-Id: <199906292112.RAA21199@delysid.gnu.org>


>Number:         1188
>Category:       libc
>Synopsis:       dlsym(RTLD_NEXT ...) returns non-default symbol (when symbol versioning is used)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    libc-gnats
>State:          open
>Class:          sw-bug
>Submitter-Id:   unknown
>Arrival-Date:   Tue Jun 29 17:20:00 EDT 1999
>Last-Modified:
>Originator:     paul@parasoft.com
>Organization:
net
>Release:        glibc-2.1 Time-stamp: <1999-02-03T17:51:49-0800 drepper>
>Environment:
redhat linux 6.0
>Description:
Gentlemen,

Program below core-dumps on redhat linux 6.0, because
dlsym(RTLD_NEXT, "fopen") returns the fopen@GLIBC_2.0, rather
than the default fopen@@GLIBC_2.1 symbol.

I believe this behaviour to be at best very confusing:
if there are multiple versions of fopen(), shouldn't
the default one be returned if I did not explicitly specify which
one I am after?

>How-To-Repeat:
compile / run the program below on redhat linux 6.0
(I think any glibc2.1 with symbol versioning would do), and it will crash
in fclose() ...

- -- cut here ---
#include <stdio.h>
#include <dlfcn.h>

FILE *_xx_fopen(const char *name, const char *mode)
{
    FILE *(*chain1)() = dlvsym(RTLD_NEXT, "fopen", "GLIBC_2.1");
    FILE *(*chain2)() = dlsym(RTLD_NEXT, "fopen");

    if (chain1 != chain2) {
        fprintf(stderr, "fopen()s differ: %p vs %p\n", chain1, chain2);
    }
    return chain2(name, mode);
}

main()
{
    char buf[1024];

    FILE *in;

    if ((in = _xx_fopen("/etc/passwd", "r"))) {
        while (fgets(buf, sizeof(buf), in)) {
            printf("%s", buf);
        }
        fclose(in);
    }
    return 0;
}
- -- cut here ---
$ gdb a.out
GNU gdb 4.17.0.11 with Linux support
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 "i386-redhat-linux"...
(gdb) r
fopen()s differ: 0x4006be40 vs 0x4006e3a0
... password stuff deleted ...

Program received signal SIGSEGV, Segmentation fault.
0x4006ba70 in _IO_new_fclose (fp=0x8049820) at iofclose.c:45
iofclose.c:45: No such file or directory.
(gdb) bt
#0  0x4006ba70 in _IO_new_fclose (fp=0x8049820) at iofclose.c:45
#1  0x804865c in main () at linux2_IO.c:25
#2  0x40032cb3 in __libc_start_main (main=0x80485e8 <main>, argc=1, 
    argv=0xbffff704, init=0x80483d4 <_init>, fini=0x804869c <_fini>, 
    rtld_fini=0x4000a350 <_dl_fini>, stack_end=0xbffff6fc)
    at ../sysdeps/generic/libc-start.c:78
(gdb) 
(gdb) p/a 0x4006be40
$1 = 0x4006be40 <_IO_new_fopen>
(gdb) p/a 0x4006e3a0
$2 = 0x4006e3a0 <_IO_old_fopen>
(gdb) 

%0
>Fix:
>Audit-Trail:
>Unformatted:


------------------------------

End of forwarda7HNMQ Digest
***************************



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

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