This is the mail archive of the libc-alpha@sourceware.org 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]
Other format: [Raw text]

Re: vi and glibc 2.12: Assertion `_rtld_global_ro._dl_pagesize != 0


hi all,

afaics the getpagesize() behaves differently for static and shared libc
parts used in the testcase. here's extended example:

$ cat a.c
#include <sys/types.h>
#include <elf.h>
#include <pwd.h>
#include <stdio.h>

#if ( __WORD_BITS__ == 32 )
typedef Elf32_auxv_t auxv_t;
#else
typedef Elf64_auxv_t auxv_t;
#endif

int main( int argc, char const* argv[] )
{
        auxv_t *auxv;
        for( ; *argv; argv++ ) ; /* skip argv... */
        argv++; /* skip null */
        for( ; *argv; argv++ ) ; /* skip envp... */
        argv++; /* skip null */
        for ( auxv = (auxv_t *)argv; auxv->a_type != AT_NULL; auxv++ )
                printf( "auxv: type %zu, value 0x%zx\n", auxv->a_type, auxv-
>a_un.a_val );
        getpwnam( "root" );
        return 0;
}

$ gcc a.c -Wall -g2 -static
/home/users/pluto/tmp/ccEHtquQ.o: In function `main':
/home/users/pluto/src/bugs/a.c:21: warning: Using 'getpwnam' in statically 
linked applications
                     requires at runtime the shared libraries from the glibc 
version used for linking

(gdb) b __getpagesize
Breakpoint 1 at 0x40c570
(gdb) r
Starting program: /home/users/pluto/src/bugs/a.out

Breakpoint 1, 0x000000000040c570 in getpagesize ()
(gdb) bt
#0  0x000000000040c570 in getpagesize ()    <=== here we're in static part of 
libc linked into a.out
#1  0x00000000004024f2 in ptmalloc_init ()
#2  0x0000000000000000 in ?? ()
(gdb) disassemble
Dump of assembler code for function getpagesize:
0x040c570 <getpagesize+0>: sub $0x8,%rsp
0x040c574 <getpagesize+4>: mov 0x2981fd(%rip),%rax # 0x6a4778 <_dl_pagesize>
                                                     ^^^^^^^^^^^^^^^^^^^^^^
                                                    address/symbol looks fine.
(gdb) p/x $rip
$1 = 0x40c574
(gdb) p/x $rax
$2 = 0x406500
(gdb) si
0x000000000040c57b in getpagesize ()
(gdb) p/x $rax
$3 = 0x1000              <== 4kB, ok.

(gdb) c
auxv: type 33, value 0x7ffff7ffe000
auxv: type 16, value 0xbfebfbff
auxv: type 6, value 0x1000               <=== AT_PAGESZ looks fine.
auxv: type 17, value 0x64
auxv: type 3, value 0x400040
auxv: type 4, value 0x38
auxv: type 5, value 0x6
auxv: type 7, value 0x0
auxv: type 8, value 0x0
auxv: type 9, value 0x400340
auxv: type 11, value 0x3e8
auxv: type 11, value 0x3e8
auxv: type 12, value 0x3e8
auxv: type 13, value 0x3e8
auxv: type 14, value 0x3e8
auxv: type 23, value 0x0
auxv: type 25, value 0x7fffffffe249
auxv: type 31, value 0x7fffffffefd7
auxv: type 15, value 0x7fffffffe259
Continuing.

Breakpoint 1, __getpagesize () at ../sysdeps/unix/sysv/linux/getpagesize.c:30
(gdb) disassemble
Dump of assembler code for function __getpagesize:
0x00007ffff7b32380 <__getpagesize+0>:   sub    $0x8,%rsp
0x00007ffff7b32384 <__getpagesize+4>:   mov    0x29bafd(%rip),%rax
                                               # 0x7ffff7dcde88 <free+3445888>
                                                         ^^^^^^^^^^^^^^^
                                               and now we're inside libc.so,
                                                it doesn't look good

(gdb) bt
#0  __getpagesize () at ../sysdeps/unix/sysv/linux/getpagesize.c:30
#1  0x00007ffff7add2f2 in ptmalloc_init_minimal () at arena.c:415
#2  ptmalloc_init () at arena.c:485
#3  0x00007ffff7ade077 in malloc_hook_ini (sz=568, caller=<value optimized 
out>) at hooks.c:37
#4  0x00007ffff7aca1eb in __fopen_internal (filename=0x7ffff7ddd659 
"/etc/passwd", mode=0x7ffff7ddd4e0 "re", is32=1) at ../libio/iofopen.c:76
#5  0x00007ffff7dd9fd3 in internal_setent (stayopen=0) at nss_files/files-
XXX.c:80
#6  0x00007ffff7dda432 in _nss_files_getpwnam_r (name=0x476461 "root", 
result=0x6a3040, buffer=0x6a61e0 "", buflen=1024, errnop=0x6a5230) at 
nss_files/files-pwd.c:33
#7  0x000000000040bf35 in getpwnam_r ()
#8  0x0000000000000430 in ?? ()
#9  0xffffffffffffffd0 in ?? ()
#10 0x00000000006a5260 in ?? ()
#11 0x00007fffffffde18 in ?? ()
#12 0x00007ffff7dda3e0 in _nss_files_getpwent_r (result=0x476461, 
buffer=0x6a3040 "", buflen=1024, errnop=0x476461) at nss_files/files-XXX.c:293
#13 0x00000000006a5208 in ?? ()
#14 0x0000000000400b80 in ?? ()
#15 0x0000000000000001 in ?? ()
#16 0x0000000000400b80 in ?? ()
#17 0x00007fffffffde60 in ?? ()
#18 0x00000000004004dc in main

(gdb) c
a.out: ../sysdeps/unix/sysv/linux/getpagesize.c:32: __getpagesize: Assertion 
`_rtld_global_ro._dl_pagesize != 0' failed.
Continuing.

Program received signal SIGABRT, Aborted.
0x00007ffff7a98ad5 in raise (sig=6) at 
../nptl/sysdeps/unix/sysv/linux/raise.c:64


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