Clemens Buchacher <[EMAIL PROTECTED]> writes: > The appended change fixes the problem for me.
...and is evidence that the libc used is broken: res is supposed to contain garbage because getaddrinfo() wasn't successful and res wasn't initialized. Please be sure to have gcc and other compilation stuff installed, then save the attached program to gaitest.c, then type: gcc -O -o gaitest gaitest.c ./gaitest ; echo $? and paste the output. Please include information on your libc (use dpkg). Expected output: ----------------------------------------------------------------------------- gai error: Name or service not known ai is: 0xdeadbeef <- this is a sentinel initialization... attempting to free ai... caught sigsegv, aborting! 1 ----------------------------------------------------------------------------- It doesn't make a difference with "Temporary failure in name resolution" either. And this happens on FreeBSD 6.2-PRERELEASE i686, a fully patched Solaris 8/SPARC, SUSE Linux 9.2 i686, 10.0 i686, NetBSD 3.1 i386 - so taking the patch upstream would make matters worse. -- Matthias Andree
#include <sys/socket.h> #include <netdb.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <signal.h> #include <unistd.h> void catchsegv(int sig) { const char *es = "caught sigsegv, aborting!\n"; (void)sig; write(2, es, strlen(es)); _exit(EXIT_FAILURE); } int main(void) { struct addrinfo *ai = 0xdeadbeef; struct addrinfo hints; int e; signal(SIGSEGV, catchsegv); memset(&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; hints.ai_family = AF_UNSPEC; hints.ai_flags = AI_CANONNAME; e = getaddrinfo("invalid.invalid", NULL, &hints, &ai); if (e) { fprintf(stderr, "gai error: %s\nai is: %p\n\nattempting to free ai...\n", gai_strerror(e), (void *)ai); freeaddrinfo(ai); fprintf(stderr, "OK, freeing seems to have worked.\n"); exit(EXIT_FAILURE); } fprintf(stderr, "success, trying to free stuff.\n"); freeaddrinfo(ai); exit(EXIT_SUCCESS); }