delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/02/18/14:58:03

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
In-Reply-To: <20090405000347.GA32495@ednor.casa.cgf.cx>
References: <c1ed4c490904041511h32bea4e0k84949ebd1ce6f57b AT mail DOT gmail DOT com> <20090405000347 DOT GA32495 AT ednor DOT casa DOT cgf DOT cx>
Date: Thu, 18 Feb 2010 19:57:46 +0000
Message-ID: <416096c61002181157u7d3c0641va59d496161683005@mail.gmail.com>
Subject: Re: TTY write deadlock
From: Andy Koppe <andy DOT koppe AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 5 April 2009 00:03, Christopher Faylor wrote:
> On Sat, Apr 04, 2009 at 03:11:06PM -0700, Josh Stone wrote:
>>I've discovered a deadlock in Cygwin which is pretty easy to
>>reproduce.?? This seems to happen on all of the console windows I can
>>find, except for running in a normal cmd.exe. =C2=A0All of these are
>>affected though: xterm, rxvt, mintty, puttycyg+cthelper, and putty
>>localhost -> cygwin sshd.
>>
>>To reproduce, run a command that produces a lot of output -- "man -P
>>cat bash" works well. =C2=A0While it's thinking about formatting that, ju=
st
>>start mashing the keyboard. =C2=A0When it starts writing out the manpage
>>while you're still mashing keys, it will lock up (100% of the time for
>>me). =C2=A0You can kill the (Schr??dinger???s) cat and life will be ok ag=
ain.
>>
>>I did some debugging and found that the terminal was stuck on
>>acquire_output_mutex in fhandler_pty_master::doecho. =C2=A0The cat process
>>had fhandler_tty_slave::write in its backtrace, so it was holding the
>>write mutex. =C2=A0The cat won't release the mutex until its data is read,
>>but the terminal won't read until after it acquires the mutex and
>>finishes doecho.
>>
>>This is on cygwin-1.7.0-45, but I can reproduce it on the 1.5 series
>>too. =C2=A0And since it happens on so many terminals and even sshd, I don=
't
>>think we can say it's the application's fault. =C2=A0I can't reproduce it
>>with a command like "man bash | cat" though, probably because the
>>difference in line buffering makes the race harder to hit.
>
> I can duplicate this. =C2=A0I'll look into fixing it ASAP.

On 12 April 2009 16:49, Christopher Faylor:
> It took me a while to remember that this is a long standing bug. =C2=A0I
> think it is possible to fix thanks to the changes in Cygwin 1.7 but it
> isn't a trivial fix. =C2=A0I will still poke at this as I have time but
> it may require a minor rewrite of the tty layer to get right.

I just stumbled into this issue while investigating a hang reported
against mintty 0.6-beta1. I found that a single keypress while catting
a large file can trigger this, and like the OP I was able to reproduce
it in all the pty-based terminals. Surprised this doesn't come up more
frequently, but I guess hacking away at the keyboard while output is
going on just isn't something one would normally do.

Anyway, as long as there isn't a fix, is there anything I could do in
mintty to work around this? Would it help to move the writing of
keyboard input to the pty device into its own thread?

Andy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019