From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15017 invoked by alias); 9 Aug 2013 14:09:33 -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 14989 invoked by uid 89); 9 Aug 2013 14:09:32 -0000 X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_YE,RDNS_NONE,SPF_SOFTFAIL autolearn=no version=3.3.1 Received: from Unknown (HELO mtaout23.012.net.il) (80.179.55.175) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 09 Aug 2013 14:09:29 +0000 Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0MR900L00OMPJY00@a-mtaout23.012.net.il> for gdb-patches@sourceware.org; Fri, 09 Aug 2013 17:09:21 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MR900LJZONKCNA0@a-mtaout23.012.net.il>; Fri, 09 Aug 2013 17:09:21 +0300 (IDT) Date: Fri, 09 Aug 2013 14:09:00 -0000 From: Eli Zaretskii Subject: Re: [RFC] Avoid invalid parameter warnings in C runtime function for mingw builtr GDB In-reply-to: <"002201ce9414$7e0d7130$7a285390$@muller"@ics-cnrs.unistra.fr> To: Pierre Muller Cc: gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <83bo57rm59.fsf@gnu.org> References: <"002201ce9414$7e0d7130$7a285390$@muller"@ics-cnrs.unistra.fr> X-SW-Source: 2013-08/txt/msg00266.txt.bz2 > From: "Pierre Muller" > Date: Thu, 8 Aug 2013 10:51:37 +0200 > > Lately I got several warnings with mingw built > GDB's: > > warning: Invalid parameter passed to C runtime function. > > Use the new "set stop-on-debug-string-event on" > command submitted previously in > http://sourceware.org/ml/gdb-patches/2013-08/msg00236.html > > I was able to trace this down to > the fopen call with mode that to "re". > As stated in the source, the "e" mode is a glibc extension > about close on exec which generates this warning. > > The patch below excludes this code if __MINGW32__ is defined, > but maybe it should be excluded if O_CLOEXEC is zero? Actually, if we want this to be portable, we should have a function to make a file handle be non-inheritable, instead of relying on glibc extensions. There _is_ a way to make a file handle non-inheritable on Windows. > diff -u -p -r1.7 filestuff.c > --- src/gdb/common/filestuff.c 26 Jun 2013 08:01:55 -0000 1.7 > +++ src/gdb/common/filestuff.c 7 Aug 2013 12:35:55 -0000 > @@ -311,6 +311,7 @@ FILE * > gdb_fopen_cloexec (const char *filename, const char *opentype) > { > FILE *result = NULL; > +#ifndef __MINGW32__ > static int fopen_e_ever_failed; > > if (!fopen_e_ever_failed) > @@ -320,17 +321,21 @@ gdb_fopen_cloexec (const char *filename, > copy = alloca (strlen (opentype) + 2); > strcpy (copy, opentype); > /* This is a glibc extension but we try it unconditionally on > - this path. */ > + this path, except when using Windows OS msvcrt dll, > + in order to avoid a output debug string event. */ > strcat (copy, "e"); > result = fopen (filename, copy); > } > +#endif > > if (result == NULL) > { > /* Fallback. */ > result = fopen (filename, opentype); > +#ifndef __MINGW32__ > if (result != NULL) > fopen_e_ever_failed = 1; > +#endif > } > > if (result != NULL) Wouldn't it be better to instead initialize fopen_e_ever_failed to 1 on MinGW? Then the rest of the code will "just work", no?