From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 71566 invoked by alias); 17 Nov 2019 19:47:01 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 71554 invoked by uid 89); 17 Nov 2019 19:47:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=UD:m, mingw64 X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 17 Nov 2019 19:46:58 +0000 Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id C60A31E180; Sun, 17 Nov 2019 14:46:56 -0500 (EST) Subject: Re: [PATCH] mingw: Fix wrong error message on connection timeout To: Orgad Shaneh , gdb-patches@sourceware.org References: From: Simon Marchi Message-ID: Date: Sun, 17 Nov 2019 19:47:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-11/txt/msg00509.txt.bz2 On 2019-11-17 5:46 a.m., Orgad Shaneh wrote: > ETIMEDOUT is defined as 138. Translating this error code to a > readable message gives "The system tried to join a drive to a directory > on a joined drive." > > Since GDB assigns this value directly, it should use a value that > the system recognizes correctly. > --- > gdb/ser-tcp.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c > index 37f64b5d08..a1baa7729e 100644 > --- a/gdb/ser-tcp.c > +++ b/gdb/ser-tcp.c > @@ -40,9 +40,8 @@ > > #ifdef USE_WIN32API > #include > -#ifndef ETIMEDOUT > +#undef ETIMEDOUT > #define ETIMEDOUT WSAETIMEDOUT > -#endif > /* Gnulib defines close too, but gnulib's replacement > doesn't call closesocket unless we import the > socketlib module. */ > -- > 2.24.0.windows.1.2.g59df941196 > Hi Orgad, Thanks for the patch. I'd like if we could understand the situation a bit better first, because it looks a bit confusing. Reading the thread where this ifndef has been introduced: https://sourceware.org/ml/gdb-patches/2011-10/msg00759.html the conclusion at the time was that all ETIMEDOUT/WSAETIMEDOUT definitions on mingw64 had the same value, 10060. Looking now, it has been changed to 138: https://github.com/mirror/mingw-w64/blob/3ac71ed3105c2989ba378e2e88d9405f65797178/mingw-w64-headers/crt/errno.h#L221-L224 int this particular commit: https://github.com/mirror/mingw-w64/commit/afae094979944d2d63dbbae125e4a5664538da6c The comment still reads "Defined as WSAETIMEDOUT.", although that doesn't seem true anymore. So the first question is: if strerror(ETIMEDOUT) on mingw64 returns an unrelated error string, is it a mingw64 but? Has it been reported there? While searching for "ETIMEDOUT mingw64", I stumbled on this Stack Overflow answer: https://stackoverflow.com/questions/13523532/strerror-with-mingw-w64 That made me realize that we have imported the strerror_r-posix gnulib module recently. And see here, it specifically handles ETIMEDOUT: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gnulib/import/strerror-override.c;h=9bc9b1895108485403cf8cb9e29723eccc009382;hb=HEAD#l82 So please try to build the current master and see you see the right error string now. Also, since we import the errno gnulib module, which defines ETIMEDOUT, I am pretty sure we actually could get right of these lines altogether: #ifndef ETIMEDOUT #define ETIMEDOUT WSAETIMEDOUT #endif Simon