Opened 16 years ago

Closed 14 years ago

#3804 closed bug (fixed)

getaddrinfo() reported buggy by Python ./configure script

Reported by: haiqu Owned by: scottmc
Priority: normal Milestone: R1
Component: System/Kernel Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Platform: x86

Description

While trying to configure Python 3.1a2 with the --with-ipv6 option, the script indicated that the implementation of getaddrinfo() was buggy (it tests specifically for a known bug evidently) and ended with a fatal error.

Disabling the option also shows the bug when it is tested, but since this bug only affects ipv6 the fatal error message was not issued in this latter case.

Change History (4)

comment:1 by haiqu, 16 years ago

Here's the relevant piece of test script taken from config.in:

AC_MSG_CHECKING(getaddrinfo bug)
AC_TRY_RUN([
#include <sys/types.h>
#include <netdb.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>

main()
{
  int passive, gaierr, inet4 = 0, inet6 = 0;
  struct addrinfo hints, *ai, *aitop;
  char straddr[INET6_ADDRSTRLEN], strport[16];

  for (passive = 0; passive <= 1; passive++) {
    memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_UNSPEC;
    hints.ai_flags = passive ? AI_PASSIVE : 0;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_protocol = IPPROTO_TCP;
    if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
      (void)gai_strerror(gaierr);
      goto bad;
    }
    for (ai = aitop; ai; ai = ai->ai_next) {
      if (ai->ai_addr == NULL ||
          ai->ai_addrlen == 0 ||
          getnameinfo(ai->ai_addr, ai->ai_addrlen,
                      straddr, sizeof(straddr), strport, sizeof(strport),
                      NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
        goto bad;
      }
      switch (ai->ai_family) {
      case AF_INET:
        if (strcmp(strport, "54321") != 0) {
          goto bad;
        }
        if (passive) {
          if (strcmp(straddr, "0.0.0.0") != 0) {
            goto bad;
          }
        } else {
          if (strcmp(straddr, "127.0.0.1") != 0) {
            goto bad;
          }
        }
        inet4++;
        break;
      case AF_INET6:
        if (strcmp(strport, "54321") != 0) {
          goto bad;
        }
        if (passive) {
          if (strcmp(straddr, "::") != 0) {
            goto bad;
          }
        } else {
          if (strcmp(straddr, "::1") != 0) {
            goto bad;
          }
        }
        inet6++;
        break;
      case AF_UNSPEC:
        goto bad;
        break;
      default:
        /* another family support? */
        break;
      }
    }
  }

  if (!(inet4 == 0 || inet4 == 2))
    goto bad;
  if (!(inet6 == 0 || inet6 == 2))
    goto bad;

  if (aitop)
    freeaddrinfo(aitop);
  exit(0);

 bad:
  if (aitop)
    freeaddrinfo(aitop);
  exit(1);
}
],
AC_MSG_RESULT(good)
buggygetaddrinfo=no,
AC_MSG_RESULT(buggy)
buggygetaddrinfo=yes,
AC_MSG_RESULT(buggy)
buggygetaddrinfo=yes)], [
AC_MSG_RESULT(no)
buggygetaddrinfo=yes
])

if test "$buggygetaddrinfo" = "yes"; then
	if test "$ipv6" = "yes"; then
		echo 'Fatal: You must get working getaddrinfo() function.'
		echo '       or you can specify "--disable-ipv6"'.
		exit 1
	fi
else
	AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
fi

comment:2 by scottmc, 14 years ago

Owner: changed from axeld to scottmc
Status: newassigned

comment:3 by scottmc, 14 years ago

This was probably fixed with hrev38748.

for Python 3.1.2, you need to add a check in configure.in for socket in network so that it picks up -lnetwork. Add this just after the AC_CHECK_LIB(socket, socket line:

AC_CHECK_LIB(network, socket, [LIBS="-lnetwork $LIBS"], [], $LIBS)

The configure option in 3.2.1 is --enable-ipv6 instead of --with-ipv6. It's no longer failing with any fatal error. I do not see this error show up, so it's most likely been fixed. Note that ipv6 is still being worked on for Haiku so don't expect that to work yet, but this issue seems to be fixed now.

comment:4 by scottmc, 14 years ago

Resolution: fixed
Status: assignedclosed

For related discussion see: http://bugs.python.org/issue1282647 and http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=52195, which seems to indicate that this was fixed with the addition of the newer getaddrinfo.c in hrev38748.

Note: See TracTickets for help on using tickets.