netdb.h redefines "h_addr"
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
eglibc (Ubuntu) |
Invalid
|
Wishlist
|
Unassigned |
Bug Description
The attached code compiles allright (gcc test.c -o test) but when I run it segfaults :
% ./test example.com 80
toto
phocean.net
resolv: phocean.net
zsh: segmentation fault ./test phocean.net 80
Debug session (attached) shows that the resolv function is working as expected, but something on the stack gets crafted and it is unable to return to the main section.
The weired thing is that it compiles and works very well on all others distro I had as virtual machines : Fedora 13 32bits & 64bits, openSUSE 11.2 64bits and Debian 5 32bits.
I also took the binary from one of these VM and ran it on Ubuntu, and it worked.
The binary from Ubuntu crashes anywhere else.
That's why I presume it is libc6 related.
Error in /var/log/messages :
kernel: [81039.332829] test[25870]: segfault at 7fff6d799f39 ip 000000000040077f sp 00007fff7b852b40 error 6 in test[400000+1000]
ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: libc6 2.11.1-0ubuntu7.1
ProcVersionSign
Uname: Linux 2.6.32-22-generic x86_64
Architecture: amd64
Date: Fri Jun 4 20:20:17 2010
InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release amd64 (20100429)
ProcEnviron:
PATH=(custom, user)
LANG=fr_FR.utf8
SHELL=/bin/zsh
SourcePackage: eglibc
summary: |
- segfault only when compiled on Lucid + incorrect stack size calculation when building with -O0 |
Changed in eglibc (Ubuntu): | |
status: | New → Confirmed |
affects: | eglibc (Ubuntu) → gcc-4.4 (Ubuntu) |
summary: |
- incorrect stack size calculation when building with -O0 + netdb.h redefines "h_addr" |
Changed in eglibc (Ubuntu): | |
importance: | Undecided → Wishlist |
status: | Confirmed → Triaged |
Here's a more minimal test case. It looks like the compiler isn't correctly calculating function stack sizes when building without optimization.
$ gcc -Wall test.c -o test -O1
$ ./test
74.125.127.104
$ gcc -Wall test.c -o test -O0
$ ./test
74.125.127.103
Segmentation fault (core dumped)
Happens with gcc-snapshot in Maverick too:
$ /usr/lib/ gcc-snapshot/ bin/gcc -Wall test.c -o test -O0
$ ./test
74.125.127.99
Segmentation fault (core dumped)