From: Sergio Durigan Junior <sergiodj@redhat.com>
To: GDB Patches <gdb-patches@sourceware.org>
Cc: Bernhard Wodok <barto@gmx.net>,
Paul Carroll <pcarroll@codesourcery.com>,
Sergio Durigan Junior <sergiodj@redhat.com>
Subject: [PATCH] Fix PR win32/24284: tcp_auto_retry doesn't work in MinGW
Date: Tue, 27 Aug 2019 15:50:00 -0000 [thread overview]
Message-ID: <20190827155013.31610-1-sergiodj@redhat.com> (raw)
This was reported by Bernhard Wodok, along with a patch to fix the
issue. I adjusted the patch a bit, and I'm submitting the patch on
his behalf.
According to Bernhard, the issue can be reproduced by doing:
1. start gdb
2. enter 'target remote :2345'
3. observe that it throws a "connection refused" error immediately
instead of waiting and throwing a timeout error
I.e., I believe it can be reproduced by our current tests, which is
why I'm not proposing any extra tests here (well, I don't use nor have
any Windows system to test this, so...).
The problem happens because we call 'gdb_select' passing 0 as its
first argument, which, when using MinGW, ends up using the
'gdb_select' version from mingw-hdep.c, and when the first argument is
0 this means that WaitForMultipleObjects will be called with 0 as its
first argument as well. According to the MS API docs, this is
forbidden:
https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitformultipleobjects
The proposed fix is simple: we just call Sleep when N == 0 (and when
TIMEOUT is non-NULL), and return 0. It makes sense to me.
Both Bernhard and Paul Carroll confirmed that the fix works. I'm
Cc'ing Bernhard in case you have any questions about the patch.
OK?
gdb/ChangeLog:
2019-08-27 Bernhard Wodok <barto@gmx.net>
Sergio Durigan Junior <sergiodj@redhat.com>
PR win32/24284
* mingw-hdep.c (gdb_select): Handle case when 'n' is zero.
---
gdb/mingw-hdep.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/gdb/mingw-hdep.c b/gdb/mingw-hdep.c
index 44fb22e9a1..1710251c51 100644
--- a/gdb/mingw-hdep.c
+++ b/gdb/mingw-hdep.c
@@ -64,6 +64,17 @@ gdb_select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
int num_ready;
size_t indx;
+ if (n == 0)
+ {
+ /* The MS API says that the first argument to
+ WaitForMultipleObjects cannot be zero. That's we just use
+ a regular Sleep here. */
+ if (timeout != NULL)
+ Sleep (timeout->tv_sec * 1000 + timeout->tv_usec / 1000);
+
+ return 0;
+ }
+
num_ready = 0;
num_handles = 0;
num_scbs = 0;
--
2.21.0
next reply other threads:[~2019-08-27 15:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-27 15:50 Sergio Durigan Junior [this message]
2019-08-29 12:15 ` Pedro Alves
2019-08-29 16:36 ` Sergio Durigan Junior
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=20190827155013.31610-1-sergiodj@redhat.com \
--to=sergiodj@redhat.com \
--cc=barto@gmx.net \
--cc=gdb-patches@sourceware.org \
--cc=pcarroll@codesourcery.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