From: Daniel Jacobowitz <drow@false.org>
To: Masaki Muranaka <monaka@monami-software.com>,
gdb-patches@sourceware.org
Subject: Re: [patch] Crashed cross gdb/MinGW host
Date: Sat, 10 Jun 2006 18:25:00 -0000 [thread overview]
Message-ID: <20060610182507.GA802@nevyn.them.org> (raw)
In-Reply-To: <20060519185257.GA2667@trixie.casa.cgf.cx>
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 <dan@codesourcery.com>
* 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
next prev parent reply other threads:[~2006-06-10 18:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-19 10:45 Masaki Muranaka
2006-05-19 20:46 ` Christopher Faylor
2006-05-20 1:14 ` Masaki Muranaka
2006-06-10 18:25 ` Daniel Jacobowitz [this message]
2006-06-10 20:41 ` Christopher Faylor
2006-06-11 10:00 ` Masaki Muranaka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060610182507.GA802@nevyn.them.org \
--to=drow@false.org \
--cc=gdb-patches@sourceware.org \
--cc=monaka@monami-software.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox