From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9923 invoked by alias); 23 Jun 2014 12:25:16 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 9911 invoked by uid 89); 23 Jun 2014 12:25:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: calimero.vinschen.de Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Jun 2014 12:25:12 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 86D198E0C66; Mon, 23 Jun 2014 14:25:10 +0200 (CEST) Date: Mon, 23 Jun 2014 12:25:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: getaddrinfo : Non-recoverable failure in name resolution Message-ID: <20140623122510.GD1803@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <53A81259.4080300@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="iVCmgExH7+hIHJ1A" Content-Disposition: inline In-Reply-To: <53A81259.4080300@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2014-06/txt/msg00352.txt.bz2 --iVCmgExH7+hIHJ1A Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1911 Hi Marco, On Jun 23 13:41, Marco Atzeri wrote: > Hi, > the attached two test programs should perform exactly the same call > to getaddrinfo for 127.0.0.1 >=20 > however on 32 bit > CYGWIN_NT-6.1-WOW64 1.7.30(0.272/5/3) 2014-05-23 10:36 i686 Cygwin >=20 > 32 $ ./getaddrinfo_test-1_32 > 127.0.0.1 ai_addr > 02 00 00 00 7f 00 00 01 00 00 00 00 00 00 00 00 >=20 > 32 $ ./getaddrinfo_test-2_32 > 127.0.0.1 ai_addr > 02 00 00 00 7f 00 00 01 00 00 00 00 00 00 00 00 >=20 > while on 64 bit > CYGWIN_NT-6.1 1.7.30(0.272/5/3) 2014-05-23 10:36 x86_64 Cygwin >=20 > 64 $ ./getaddrinfo_test-1_64 > 127.0.0.1 ai_addr > 02 00 00 00 7f 00 00 01 00 00 00 00 00 00 00 00 >=20 > 64 $ ./getaddrinfo_test-2_64 > getaddrinfo: Non-recoverable failure in name resolution >=20 >=20 > Am I missing something ? > The second way is currently used on postgresql in several places, > but it seems to fail only for "127.0.0.1" I don't know why this only fails for "127.0.0.1". But this is clearly a problem in the 64 bit Cygwin DLL. What happens is that the field ai_addrlen is defined as socklen_t in POSIX, but as size_t in the W32 API. On 64 bit, socklen_t is 4 bytes while size_t is 8 bytes. Setting all the hintp members manually (in contrast to calloc'ing it or memset'ing it to 0) leaves the 4 upper bytes of the ai_addrlen untouched. This in turn leads to a high probability that ai_addrlen has an invalid value when entering Winsock's getsockopt. I'm really surprised this hasn't been hit before. I'm going to fix that in Cygwin by setting the upper 4 bytes of ai_addrlen to 0 explicitely. For the time being, you might prepend memset (&hintp, 0, sizeof hintp); to the code, prior to setting the elements manually. Thanks for the testcase. Much appreciated, Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --iVCmgExH7+hIHJ1A Content-Type: application/pgp-signature Content-length: 819 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJTqBymAAoJEPU2Bp2uRE+guGgP/joaKW9wFQovpw5XmjeIZ0bP mL6RXDP9/urWL815FUJoXQXMxWj1tV6hvFZP4HzdexRKWENB7rtfJGOlJeD89S+G ydt1wjSjzjfxw//Cw8FlCUZyvmIE5cIPYAlfT3YVmWQ9l/+HEd4Q46Wpo8vCygbJ /ezLbDkHQ9pBwd4Fr3Djo/T2n4tZ/vSS6QZG6ivRWUWi3UPZ2WquWKpFc8PTcAao QDzJ4hDIZUJnB5SZfzc3urdy+b/4wB4ExjAjEIU9f7tUVDOxienMeT1VDfkB26WP uNEqT27f+qxaPm6pPw+k+4ZaPNpTKcGjYsoInl9/3r2H6n1aec0EL3ce0AXCT6vn Qoyezd4RaSWrkEiulvGc5uiooKtOmXV1g3tRsDZLEdyF8EquYka9CNV2pLSA5m6F b72xX+H1ML7SX7Cq98zrYDfNf2MLcUl0CV7yaZgScWuF6LUcE2HRGEvCn0ho3xnp kSE1/oMWH3+g38580cc+ITF3H/RurB/KjQMQMN+EZpWh4/b/rR1SLxFSGqHoSJcq V8Ae8fBNSpZe30Dmkmu8XJIgFrlsrxTJmixz/3BVFM+XfMkGXbABCCZWCnCV2QSu YvQ1TbX0Z64vcwZ4uOd2QwcadG90sPC0/Q0EIP1gW9B3+avvr4IcJz5tzmUWReN0 t6LRG7qpn5qRNJEMQhRQ =DHNT -----END PGP SIGNATURE----- --iVCmgExH7+hIHJ1A--