Package: libc6-dev Version: 2.24-11+deb9u1 Severity: normal Dear Maintainer,
with glibc 2.24 (reproducible on 64-bit Debian 9 or Ubuntu 17.04), gethostbyname() always segfaults if the binary was linked statically: $ echo -e "#include <netdb.h>\nint main(void){gethostbyname(\"foo\");}" >foo.c && \ gcc -g -static foo.c && ./a.out /tmp/ccp8JNGC.o: In function `main': /tmp/foo.c:2: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking Segmentation fault $ gdb a.out GNU gdb (Debian 7.12-6) 7.12.0.20161007-git [...] Reading symbols from a.out...done. (gdb) run Starting program: /tmp/a.out [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Program received signal SIGSEGV, Segmentation fault. 0x0000000000000000 in ?? () (gdb) bt #0 0x0000000000000000 in ?? () #1 0x00007ffff72ac040 in __pthread_initialize_minimal_internal () at nptl-init.c:460 #2 0x00007ffff72ab5e1 in _init () at ../sysdeps/x86_64/crti.S:72 #3 0x00007ffff76cc830 in ?? () from /lib/x86_64-linux-gnu/libnss_myhostname.so.2 #4 0x0000000000478a7a in call_init.part () #5 0x0000000000478c35 in _dl_init () #6 0x000000000047089e in dl_open_worker () #7 0x000000000046e0f4 in _dl_catch_error () #8 0x000000000047024c in _dl_open () #9 0x0000000000439ba2 in do_dlopen () #10 0x000000000046e0f4 in _dl_catch_error () #11 0x0000000000439bd7 in dlerror_run () #12 0x0000000000439da3 in __libc_dlopen_mode () #13 0x0000000000436b3b in __nss_lookup_function () #14 0x0000000000436d45 in __nss_next2 () #15 0x000000000043504a in gethostbyname_r () #16 0x0000000000434d93 in gethostbyname () #17 0x0000000000400b2e in main () at foo.c:2 In my upstream bug report, a commenter noted that this weren't reproducible in Fedora's glibc 2.24 or 2.25, suggesting this "could be a Debian or Ubuntu patch": https://sourceware.org/bugzilla/show_bug.cgi?id=21975 -- System Information: Debian Release: 9.1 APT prefers stable APT policy: (500, 'stable') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.9.0-3-amd64 (SMP w/64 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages libc6-dev depends on: ii libc-dev-bin 2.24-11+deb9u1 ii libc6 2.24-11+deb9u1 ii linux-libc-dev 4.9.30-2+deb9u3 libc6-dev recommends no packages. Versions of packages libc6-dev suggests: pn glibc-doc <none> ii manpages-dev 4.10-2 -- no debconf information