getaddrinfo() segfaults when linked statically

Bug #647527 reported by Loïc Minier
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
eglibc (Ubuntu)
New
Undecided
Unassigned

Bug Description

Hi

While building qemu statically, I get a SEGV on startup when it calls getaddrinfo() for the VNC listener; it turns out this is easily reproducible with a small C test case when building statically.

gcc -O0 -o foo foo.c && ./foo
=> works
gcc -static -O0 -o foo foo.c && ./foo
=> segvs

(gdb) run
Starting program: /home/lool/foo

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7ac79e3 in arena_get2 (a_tsd=0x7ffff7dcde40, size=100)
    at arena.c:1072
1072 arena.c: Aucun fichier ou dossier de ce type.
        in arena.c
(gdb) bt
#0 0x00007ffff7ac79e3 in arena_get2 (a_tsd=0x7ffff7dcde40, size=100)
    at arena.c:1072
#1 0x00007ffff7acb53f in __libc_malloc (bytes=100) at malloc.c:3672
#2 0x00007ffff7abb1c9 in _IO_vasprintf (result_ptr=0x7fffffffdc68,
    format=0x64 <Address 0x64 out of bounds>, args=0x0) at vasprintf.c:52
#3 0x00007ffff7a9f8b8 in ___asprintf (string_ptr=0x0,
    format=0x64 <Address 0x64 out of bounds>) at asprintf.c:37
#4 0x00007ffff7a7ba33 in __assert_fail (
    assertion=0x7ffff7b9c6d8 "_rtld_global_ro._dl_pagesize != 0",
    file=<value optimised out>, line=32,
    function=0x7ffff7b97acd "__getpagesize") at assert.c:63
#5 0x00007ffff7b2e0c8 in __getpagesize ()
    at ../sysdeps/unix/sysv/linux/getpagesize.c:32
#6 0x00007ffff7ac6d72 in ptmalloc_init_minimal () at arena.c:415
#7 ptmalloc_init () at arena.c:485
#8 0x00007ffff7acb5d7 in malloc_hook_ini (sz=0, caller=0x64) at hooks.c:37
#9 0x00007ffff7ab73ab in __fopen_internal (
    filename=0x7ffff7ddc4f0 "/etc/hosts",
    mode=0x64 <Address 0x64 out of bounds>, is32=0)
    at ../sysdeps/wordsize-64/../../libio/iofopen.c:76
#10 0x00007ffff7dd71e3 in internal_setent (stayopen=0)
    at nss_files/files-XXX.c:80
#11 0x00007ffff7dd7a1c in _nss_files_gethostbyname4_r (
    name=<value optimised out>, pat=0x64, buffer=0x7fffffffde60 "",
    buflen=1024, errnop=0x1, herrnop=0x0, ttlp=0x0)
    at nss_files/files-hosts.c:329
#12 0x000000000040e3d6 in gaih_inet ()
#13 0x0000000000410062 in getaddrinfo ()
#14 0x00000000004004a5 in main ()

Cheers,

ProblemType: Bug
DistroRelease: Ubuntu 10.10
Package: libc6 2.12.1-0ubuntu6
ProcVersionSignature: Ubuntu 2.6.35-20.29-generic 2.6.35.4
Uname: Linux 2.6.35-20-generic x86_64
Architecture: amd64
Date: Sat Sep 25 16:25:19 2010
ProcEnviron:
 LANGUAGE=fr_FR:fr:en_GB:en
 PATH=(custom, user)
 LANG=fr_FR.UTF-8
 SHELL=/bin/zsh
SourcePackage: eglibc

Revision history for this message
Loïc Minier (lool) wrote :
Revision history for this message
Symax (ayourk) wrote :

I believe that Gentoo already has a fix for this. I'm going to attempt to use their patch to verify

Gentoo problem report: http://bugs.gentoo.org/332927

Revision history for this message
Richard Kapolnai (richardkapolnai) wrote :

I think bug #672352 at https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/672352 is also related to this bug.

It would be really nice to have a patch for it, it affects some of my colleagues.

Interestingly, on my box it raises a signal 6 instead of signal 11:

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

Program received signal SIGABRT, Aborted.
0x00110416 in __kernel_vsyscall ()
(gdb) bt
#0 0x00110416 in __kernel_vsyscall ()
#1 0x00147941 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2 0x0014ae42 in abort () at abort.c:92
#3 0x001408e8 in __assert_fail (assertion=0x259dbc "_rtld_global_ro._dl_pagesize != 0", file=0x259d90 "../sysdeps/unix/sysv/linux/getpagesize.c", line=32,
    function=0x254b88 "__getpagesize") at assert.c:81
#4 0x001e612f in __getpagesize () at ../sysdeps/unix/sysv/linux/getpagesize.c:32
#5 0x00189c85 in ptmalloc_init_minimal () at arena.c:415
#6 ptmalloc_init () at arena.c:485
#7 0x0018e1cc in malloc_hook_ini (sz=352, caller=0x17a11f) at hooks.c:37
#8 0x0018e0b0 in __libc_malloc (bytes=352) at malloc.c:3622
#9 0x0017a11f in __fopen_internal (filename=0x119e74 "/etc/hosts", mode=0x119e24 "re", is32=1) at iofopen.c:76
#10 0x0017a1ec in _IO_new_fopen (filename=0x119e74 "/etc/hosts", mode=0x119e24 "re") at iofopen.c:107
#11 0x00115830 in internal_setent (stayopen=0) at nss_files/files-XXX.c:80
#12 0x001162c0 in _nss_files_gethostbyname2_r (name=0x80bbdcd "localhost", af=2, result=0xbffff4b0, buffer=0xbffff200 "", buflen=512, errnop=0x80e0814,
    herrnop=0xbffff4c8) at nss_files/files-hosts.c:301
#13 0x0805a8b3 in gethostbyname2_r ()
#14 0x08054445 in gaih_inet ()
#15 0x08055e60 in getaddrinfo ()
#16 0x08048324 in main ()
(gdb) quit

Revision history for this message
Loïc Minier (lool) wrote :

Thanks; bug #672352 is indeed a dup, but has more information; will merge this bug into it

Revision history for this message
Loïc Minier (lool) wrote :

I filed bug #674073 for the SEGV versus SIGABRT; are you using i386 or amd64? I suspect this might be the reason for the difference.

It might be that the same static/dynamic initialization is the cause of the crash, or that it's simply x86-64 specific.

Revision history for this message
Richard Kapolnai (richardkapolnai) wrote :

My box is i386 but I also tried it on a chroot'ed amd64 box, the same. More details at bug #674073.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.