public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] Be truthful about reporting whether readahead is available
@ 2016-04-05  8:52 Johannes Schindelin
  2016-04-05 13:56 ` Corinna Vinschen
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Schindelin @ 2016-04-05  8:52 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Thomas Wolff

In 7346568 (Make requested console reports work, 2016-03-16), code was
introduced to report the current cursor position. It works by using a
pointer that either points to the next byte in the readahead buffer, or
to a NUL byte if the buffer is depleted, or the pointer is NULL.

These conditions are heeded in the fhandler_console::read() method, but
the condition that the pointer can point at the end of the readahead
buffer was not handled properly in the get_cons_readahead_valid()
method.

This poses a problem e.g. in Git for Windows (which uses a slightly
modified MSYS2 runtime which is in turn a slightly modified Cygwin
runtime) when vim queries the cursor position and immediately goes on to
read console input, erroneously thinking that the readahead buffer is
valid when it is already depleted instead. This condition results in an
apparent freeze that can be helped only by pressing keys repeatedly.

The full Git for Windows bug report is here:

	https://github.com/git-for-windows/git/issues/711

Let's just teach the get_cons_readahead_valid() method to handle a
depleted readahead buffer correctly.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 winsup/cygwin/fhandler.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 4610557..bd1a923 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -1453,7 +1453,8 @@ private:
   bool focus_aware () {return shared_console_info->con.use_focus;}
   bool get_cons_readahead_valid ()
   {
-    return shared_console_info->con.cons_rapoi != NULL;
+    return shared_console_info->con.cons_rapoi != NULL &&
+      *shared_console_info->con.cons_rapoi;
   }
 
   select_record *select_read (select_stuff *);
-- 
2.8.0.windows.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Be truthful about reporting whether readahead is available
  2016-04-05  8:52 [PATCH] Be truthful about reporting whether readahead is available Johannes Schindelin
@ 2016-04-05 13:56 ` Corinna Vinschen
       [not found]   ` <748397985.175721.a41cd152-02d9-4741-9845-0d01439e7852.open-xchange@email.1und1.de>
  0 siblings, 1 reply; 5+ messages in thread
From: Corinna Vinschen @ 2016-04-05 13:56 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Thomas Wolff

[-- Attachment #1: Type: text/plain, Size: 2179 bytes --]

Thomas?

Any input?

On Apr  5 10:52, Johannes Schindelin wrote:
> In 7346568 (Make requested console reports work, 2016-03-16), code was
> introduced to report the current cursor position. It works by using a
> pointer that either points to the next byte in the readahead buffer, or
> to a NUL byte if the buffer is depleted, or the pointer is NULL.
> 
> These conditions are heeded in the fhandler_console::read() method, but
> the condition that the pointer can point at the end of the readahead
> buffer was not handled properly in the get_cons_readahead_valid()
> method.
> 
> This poses a problem e.g. in Git for Windows (which uses a slightly
> modified MSYS2 runtime which is in turn a slightly modified Cygwin
> runtime) when vim queries the cursor position and immediately goes on to
> read console input, erroneously thinking that the readahead buffer is
> valid when it is already depleted instead. This condition results in an
> apparent freeze that can be helped only by pressing keys repeatedly.
> 
> The full Git for Windows bug report is here:
> 
> 	https://github.com/git-for-windows/git/issues/711
> 
> Let's just teach the get_cons_readahead_valid() method to handle a
> depleted readahead buffer correctly.
> 
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  winsup/cygwin/fhandler.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
> index 4610557..bd1a923 100644
> --- a/winsup/cygwin/fhandler.h
> +++ b/winsup/cygwin/fhandler.h
> @@ -1453,7 +1453,8 @@ private:
>    bool focus_aware () {return shared_console_info->con.use_focus;}
>    bool get_cons_readahead_valid ()
>    {
> -    return shared_console_info->con.cons_rapoi != NULL;
> +    return shared_console_info->con.cons_rapoi != NULL &&
> +      *shared_console_info->con.cons_rapoi;
>    }
>  
>    select_record *select_read (select_stuff *);
> -- 
> 2.8.0.windows.1


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fwd: Re: [PATCH] Be truthful about reporting whether readahead is available
       [not found]   ` <748397985.175721.a41cd152-02d9-4741-9845-0d01439e7852.open-xchange@email.1und1.de>
@ 2016-04-05 16:50     ` Thomas Wolff
  2016-04-05 18:47       ` Corinna Vinschen
  2016-04-06 12:23       ` Johannes Schindelin
  0 siblings, 2 replies; 5+ messages in thread
From: Thomas Wolff @ 2016-04-05 16:50 UTC (permalink / raw)
  To: cygwin-patches


>> Von: Corinna Vinschen <corinna-cygwin@cygwin.com>
>> An: cygwin-patches@cygwin.com
>> Cc: Thomas Wolff <towo@towo.net>
>> Datum: 5. April 2016 um 15:55
>> Betreff: Re: [PATCH] Be truthful about reporting whether readahead is 
>> available
>>
>> Thomas?
>>
>> Any input?
>>
Yes, let's fix the patch so. Sorry for the flaw.
Thomas

>>
>> On Apr 5 10:52, Johannes Schindelin wrote:
>>
>>> In 7346568 (Make requested console reports work, 2016-03-16), code was
>>> introduced to report the current cursor position. It works by using a
>>> pointer that either points to the next byte in the readahead buffer, or
>>> to a NUL byte if the buffer is depleted, or the pointer is NULL.
>>>
>>> These conditions are heeded in the fhandler_console::read() method, but
>>> the condition that the pointer can point at the end of the readahead
>>> buffer was not handled properly in the get_cons_readahead_valid()
>>> method.
>>>
>>> This poses a problem e.g. in Git for Windows (which uses a slightly
>>> modified MSYS2 runtime which is in turn a slightly modified Cygwin
>>> runtime) when vim queries the cursor position and immediately goes on to
>>> read console input, erroneously thinking that the readahead buffer is
>>> valid when it is already depleted instead. This condition results in an
>>> apparent freeze that can be helped only by pressing keys repeatedly.
>>>
>>> The full Git for Windows bug report is here:
>>>
>>> https://github.com/git-for-windows/git/issues/711
>>>
>>> Let's just teach the get_cons_readahead_valid() method to handle a
>>> depleted readahead buffer correctly.
>>>
>>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
>>> ---
>>> winsup/cygwin/fhandler.h | 3 ++-
>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
>>> index 4610557..bd1a923 100644
>>> --- a/winsup/cygwin/fhandler.h
>>> +++ b/winsup/cygwin/fhandler.h
>>> @@ -1453,7 +1453,8 @@ private:
>>> bool focus_aware () {return shared_console_info->con.use_focus;}
>>> bool get_cons_readahead_valid ()
>>> {
>>> - return shared_console_info->con.cons_rapoi != NULL;
>>> + return shared_console_info->con.cons_rapoi != NULL &&
>>> + *shared_console_info->con.cons_rapoi;
>>> }
>>>
>>> select_record *select_read (select_stuff *);
>>> -- 
>>> 2.8.0.windows.1
>>>
>>
>> Thanks,
>> Corinna
>>
>> -- 
>> Corinna Vinschen Please, send mails regarding Cygwin to
>> Cygwin Maintainer cygwin AT cygwin DOT com
>> Red Hat
>>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fwd: Re: [PATCH] Be truthful about reporting whether readahead is available
  2016-04-05 16:50     ` Fwd: " Thomas Wolff
@ 2016-04-05 18:47       ` Corinna Vinschen
  2016-04-06 12:23       ` Johannes Schindelin
  1 sibling, 0 replies; 5+ messages in thread
From: Corinna Vinschen @ 2016-04-05 18:47 UTC (permalink / raw)
  To: cygwin-patches

[-- Attachment #1: Type: text/plain, Size: 1929 bytes --]

On Apr  5 18:50, Thomas Wolff wrote:
> 
> >>Von: Corinna Vinschen <corinna-cygwin@cygwin.com>
> >>An: cygwin-patches@cygwin.com
> >>Cc: Thomas Wolff <towo@towo.net>
> >>Datum: 5. April 2016 um 15:55
> >>Betreff: Re: [PATCH] Be truthful about reporting whether readahead is
> >>available
> >>
> >>Thomas?
> >>
> >>Any input?
> >>
> Yes, let's fix the patch so. Sorry for the flaw.

No worries.

> Thomas
> 
> >>
> >>On Apr 5 10:52, Johannes Schindelin wrote:
> >>
> >>>In 7346568 (Make requested console reports work, 2016-03-16), code was
> >>>introduced to report the current cursor position. It works by using a
> >>>pointer that either points to the next byte in the readahead buffer, or
> >>>to a NUL byte if the buffer is depleted, or the pointer is NULL.
> >>>
> >>>These conditions are heeded in the fhandler_console::read() method, but
> >>>the condition that the pointer can point at the end of the readahead
> >>>buffer was not handled properly in the get_cons_readahead_valid()
> >>>method.
> >>>
> >>>This poses a problem e.g. in Git for Windows (which uses a slightly
> >>>modified MSYS2 runtime which is in turn a slightly modified Cygwin
> >>>runtime) when vim queries the cursor position and immediately goes on to
> >>>read console input, erroneously thinking that the readahead buffer is
> >>>valid when it is already depleted instead. This condition results in an
> >>>apparent freeze that can be helped only by pressing keys repeatedly.
> >>>
> >>>The full Git for Windows bug report is here:
> >>>
> >>>https://github.com/git-for-windows/git/issues/711
> >>>
> >>>Let's just teach the get_cons_readahead_valid() method to handle a
> >>>depleted readahead buffer correctly.

Patch applied.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fwd: Re: [PATCH] Be truthful about reporting whether readahead is available
  2016-04-05 16:50     ` Fwd: " Thomas Wolff
  2016-04-05 18:47       ` Corinna Vinschen
@ 2016-04-06 12:23       ` Johannes Schindelin
  1 sibling, 0 replies; 5+ messages in thread
From: Johannes Schindelin @ 2016-04-06 12:23 UTC (permalink / raw)
  To: Thomas Wolff; +Cc: cygwin-patches

Hi Thomas,

On Tue, 5 Apr 2016, Thomas Wolff wrote:

> > > Betreff: Re: [PATCH] Be truthful about reporting whether readahead is
> > > available
> > >
> > > Thomas?
> > >
> > > Any input?
> > >
> Yes, let's fix the patch so. Sorry for the flaw.

No big deal, thanks for the ACK!

Ciao,
Johannes

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-04-06 12:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-05  8:52 [PATCH] Be truthful about reporting whether readahead is available Johannes Schindelin
2016-04-05 13:56 ` Corinna Vinschen
     [not found]   ` <748397985.175721.a41cd152-02d9-4741-9845-0d01439e7852.open-xchange@email.1und1.de>
2016-04-05 16:50     ` Fwd: " Thomas Wolff
2016-04-05 18:47       ` Corinna Vinschen
2016-04-06 12:23       ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).