From 4623d3ff01cd48a8ff0632a1bb1000eb4200b106 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 6 Mar 2013 14:02:53 +0100 Subject: [PATCH] glibc: Fix an assertion failure in getaddrinfo.c For instance, when connected to a VPN, Emacs would randomly crash at startup: emacs: ../sysdeps/posix/getaddrinfo.c:1467: rfc3484_sort: Assertion `src->results[i].native == -1 || src->results[i].native == a2_native' failed. --- .../libraries/glibc/2.17/common.nix | 5 ++ .../libraries/glibc/2.17/glibc-rh739743.patch | 55 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 pkgs/development/libraries/glibc/2.17/glibc-rh739743.patch diff --git a/pkgs/development/libraries/glibc/2.17/common.nix b/pkgs/development/libraries/glibc/2.17/common.nix index eed51288707..ea2f3b6d140 100644 --- a/pkgs/development/libraries/glibc/2.17/common.nix +++ b/pkgs/development/libraries/glibc/2.17/common.nix @@ -49,6 +49,11 @@ stdenv.mkDerivation ({ compatibility with old NixOS installations (since NixOS used to default to blowfish). */ ./glibc-crypt-blowfish.patch + + /* Fix for random "./sysdeps/posix/getaddrinfo.c:1467: + rfc3484_sort: Assertion `src->results[i].native == -1 || + src->results[i].native == a2_native' failed." crashes. */ + ./glibc-rh739743.patch ]; postPatch = '' diff --git a/pkgs/development/libraries/glibc/2.17/glibc-rh739743.patch b/pkgs/development/libraries/glibc/2.17/glibc-rh739743.patch new file mode 100644 index 00000000000..c390b772b16 --- /dev/null +++ b/pkgs/development/libraries/glibc/2.17/glibc-rh739743.patch @@ -0,0 +1,55 @@ +2009-04-26 Aurelien Jarno + + * sysdeps/posix/getaddrinfo.c (rfc3484_sort): don't assign native + result if the result has no associated interface. + +--- + sysdeps/posix/getaddrinfo.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/sysdeps/posix/getaddrinfo.c ++++ b/sysdeps/posix/getaddrinfo.c +@@ -1456,13 +1456,13 @@ + + /* Fill in the results in all the records. */ + for (int i = 0; i < src->nresults; ++i) +- if (src->results[i].index == a1_index) ++ if (a1_index != -1 && src->results[i].index == a1_index) + { + assert (src->results[i].native == -1 + || src->results[i].native == a1_native); + src->results[i].native = a1_native; + } +- else if (src->results[i].index == a2_index) ++ else if (a2_index != -1 && src->results[i].index == a2_index) + { + assert (src->results[i].native == -1 + || src->results[i].native == a2_native); + +2009-03-15 Aurelien Jarno + + * sysdeps/posix/getaddrinfo.c (getaddrinfo): correctly detect + interface for all 127.X.Y.Z addresses. + +--- + sysdeps/posix/getaddrinfo.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +--- a/sysdeps/posix/getaddrinfo.c ++++ b/sysdeps/posix/getaddrinfo.c +@@ -2265,7 +2265,14 @@ + tmp.addr[0] = 0; + tmp.addr[1] = 0; + tmp.addr[2] = htonl (0xffff); +- tmp.addr[3] = sinp->sin_addr.s_addr; ++ /* Special case for lo interface, the source address ++ being possibly different than the interface ++ address. */ ++ if ((ntohl(sinp->sin_addr.s_addr) & 0xff000000) ++ == 0x7f000000) ++ tmp.addr[3] = htonl(0x7f000001); ++ else ++ tmp.addr[3] = sinp->sin_addr.s_addr; + } + else + {