cygwin.dll: bug with select on Windows console

Corinna Vinschen corinna-cygwin@cygwin.com
Sat Jan 9 14:42:00 GMT 2016


On Jan  9 15:36, Corinna Vinschen wrote:
> On Jan  8 15:58, john hood wrote:
> > On 1/8/16 11:29 AM, Corinna Vinschen wrote:
> > > On Jan  7 13:18, John Hood wrote:
> > >> Sorry about forgetting the testcase (which was good, actually, that
> > >> version had a bug).  I've attached it here.  This takes a single
> > >> argument, the timeout value for select() in microseconds.  A value of
> > >> 1000000 is fine for testing this issue.  Type at it, or just bang on the
> > >> keyboard with random keystrokes, and it will report the results from
> > >> select() and the characters read.  On a Windows console, it should
> > >> report an error within a few seconds.  Moving the mouse cursor over the
> > >> Windows console window while typing seems to provoke the error as well. 
> > > 
> > > No chance.  I tried this for a good hour now with the unpatched Cygwin
> > > DLL on 32 bit W7 and 64 bit W10 in 32 and 64 bit in a Windows console,
> > > and I can't provoke this error.  It just works for me.
> > 
> > My apologies for sending you down a wrong path.  Try again with
> > "socket-t 1000", which only waits 1ms.  I don't know what I was thinking
> > when I said the 1s timeout works fine.
> 
> This helped and I found the culprit.  There are, in fact, two ways to
> leave select with a timeout.  One of them only occurs in the border
> cases where a device behind a descriptor generates events which are
> not supposed to generate a select event.

I forgot to mention, this affects especially consoles (window events,
mouse events) and /dev/windows.

> If that happens, the select
> loop is supposed to loop again, but the code first checks if the timeout
> has been hit in the meantime and, if so, it breaks from the loop with a
> timeout, aka, a return value of 0.  However, in this single case, the
> code neglected to zero out the descriptor arrays, which then leads to
> the problem you encountered.
> 
> I fixed the code and took the opportunity to clean it up a little using
> basically the (fixed) patch I proposed two days ago.
> 
> I've just uploaded new developer snapshots to https://cygwin.com/snapshots/
> and a new test release 2.4.0-0.17 which contain this fix.  Please give any
> of them a try.
> 
> 
> Thanks,
> Corinna


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20160109/ba1fc6dc/attachment.sig>


More information about the Cygwin mailing list