From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4054 invoked by alias); 10 Jun 2006 18:25:15 -0000 Received: (qmail 3996 invoked by uid 22791); 10 Jun 2006 18:25:14 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Sat, 10 Jun 2006 18:25:09 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1Fp88x-00014p-3c; Sat, 10 Jun 2006 14:25:07 -0400 Date: Sat, 10 Jun 2006 18:25:00 -0000 From: Daniel Jacobowitz To: Masaki Muranaka , gdb-patches@sourceware.org Subject: Re: [patch] Crashed cross gdb/MinGW host Message-ID: <20060610182507.GA802@nevyn.them.org> Mail-Followup-To: Masaki Muranaka , gdb-patches@sourceware.org References: <0494AFF8-AB9B-40E8-A4D2-C119DEEC5248@monami-software.com> <20060519185257.GA2667@trixie.casa.cgf.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060519185257.GA2667@trixie.casa.cgf.cx> User-Agent: Mutt/1.5.11+cvs20060403 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-06/txt/msg00124.txt.bz2 On Fri, May 19, 2006 at 02:52:57PM -0400, Christopher Faylor wrote: > On Fri, May 19, 2006 at 06:47:04PM +0900, Masaki Muranaka wrote: > >My sh-elf-gdb on MinGW host was crashed when I tried to debug using the > >serial connection. Here is a patch. > > > >It's possible the another plan to remove writefds check. There is no > >support yet for writefds. > > If this is truly supposed to be an emulation of the system select(), I > think it would make sense to check both !readfds and !writefds. Sorry for letting this sit so long. I just encountered this bug today. I think I tested console and pipe when I last touched this code but failed to test ser-base. The underlying problem is actually different. The code looks like this: if (!FD_ISSET (fd, readfds) && !FD_ISSET (fd, writefds)) continue; if (FD_ISSET (fd, readfds)) ... if (FD_ISSET (fd, exceptfds)) ... See the mismatch? :-( I have committed the attached patch as obvious. It adds the missing NULL checks, and also corrects the loop check for exceptfds. -- Daniel Jacobowitz CodeSourcery 2006-06-10 Daniel Jacobowitz * mingw-hdep.c (gdb_select): Always check for NULL fd sets before calling FD_ISSET. Correct check for exceptfds which previously tested writefds. Index: mingw-hdep.c =================================================================== RCS file: /cvs/src/src/gdb/mingw-hdep.c,v retrieving revision 1.3 diff -u -p -r1.3 mingw-hdep.c --- mingw-hdep.c 24 Apr 2006 21:00:13 -0000 1.3 +++ mingw-hdep.c 10 Jun 2006 16:37:55 -0000 @@ -105,8 +105,8 @@ gdb_select (int n, fd_set *readfds, fd_s if something starts using it. */ gdb_assert (!writefds || !FD_ISSET (fd, writefds)); - if (!FD_ISSET (fd, readfds) - && !FD_ISSET (fd, exceptfds)) + if ((!readfds || !FD_ISSET (fd, readfds)) + && (!exceptfds || !FD_ISSET (fd, exceptfds))) continue; h = (HANDLE) _get_osfhandle (fd); @@ -124,13 +124,13 @@ gdb_select (int n, fd_set *readfds, fd_s except = never_handle; } - if (FD_ISSET (fd, readfds)) + if (readfds && FD_ISSET (fd, readfds)) { gdb_assert (num_handles < MAXIMUM_WAIT_OBJECTS); handles[num_handles++] = read; } - if (FD_ISSET (fd, exceptfds)) + if (exceptfds && FD_ISSET (fd, exceptfds)) { gdb_assert (num_handles < MAXIMUM_WAIT_OBJECTS); handles[num_handles++] = except; @@ -169,10 +169,11 @@ gdb_select (int n, fd_set *readfds, fd_s HANDLE fd_h; struct serial *scb; - if (!FD_ISSET (fd, readfds) && !FD_ISSET (fd, writefds)) + if ((!readfds || !FD_ISSET (fd, readfds)) + && (!exceptfds || !FD_ISSET (fd, exceptfds))) continue; - if (FD_ISSET (fd, readfds)) + if (readfds && FD_ISSET (fd, readfds)) { fd_h = handles[indx++]; /* This handle might be ready, even though it wasn't the handle @@ -183,7 +184,7 @@ gdb_select (int n, fd_set *readfds, fd_s num_ready++; } - if (FD_ISSET (fd, exceptfds)) + if (exceptfds && FD_ISSET (fd, exceptfds)) { fd_h = handles[indx++]; /* This handle might be ready, even though it wasn't the handle