From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from conssluserg-03.nifty.com (conssluserg-03.nifty.com [210.131.2.82]) by sourceware.org (Postfix) with ESMTPS id E59F13857C46 for ; Tue, 11 Aug 2020 05:00:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E59F13857C46 Received: from Express5800-S70 (v038192.dynamic.ppp.asahi-net.or.jp [124.155.38.192]) (authenticated) by conssluserg-03.nifty.com with ESMTP id 07B4xh9h004327 for ; Tue, 11 Aug 2020 13:59:44 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-03.nifty.com 07B4xh9h004327 X-Nifty-SrcIP: [124.155.38.192] Date: Tue, 11 Aug 2020 13:59:48 +0900 From: Takashi Yano To: cygwin@cygwin.com Subject: Re: Race condition hangs on multiple mintty/tcsh? Brad Wetmore Message-Id: <20200811135948.959c10de83b8ccfa35f4281a@nifty.ne.jp> In-Reply-To: <3d594543-c992-a22c-4631-f786cf34f76b@towo.net> References: <1988bd34-7a17-e70f-bf23-0044f30c8687@towo.net> <1193403444.420395.1596669799506@mail.yahoo.com> <3d594543-c992-a22c-4631-f786cf34f76b@towo.net> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart=_Tue__11_Aug_2020_13_59_48_+0900_vwm=him6qccruPyq" X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Aug 2020 05:00:12 -0000 This is a multi-part message in MIME format. --Multipart=_Tue__11_Aug_2020_13_59_48_+0900_vwm=him6qccruPyq Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi Thomas, On Thu, 6 Aug 2020 15:31:24 +0200 Thomas Wolff wrote: > Am 06.08.2020 um 13:46 schrieb Thomas Wolff: > > Am 06.08.2020 um 01:23 schrieb Kevin Schnitzius via Cygwin: > >> On Wednesday, August 5, 2020, 06:56:48 PM EDT, Thomas Wolff > >> wrote: > >>> Am 04.08.2020 um 12:02 schrieb Thomas Wolff: > >>>> Am 04.08.2020 um 00:13 schrieb Brad Wetmore via Cygwin: > >>>>> Hi, > >>>>> > >>>>> I generally kick off multiple (10) mintty sessions, and place them > >>>>> around the screen. > >>>>> > >>>>> C:/cygwin64/bin/mintty.exe -i /Cygwin-Terminal.ico \ > >>>> --position @3 --position 120,0 --size 80x71 /bin/tcsh & > >>>>> C:/cygwin64/bin/mintty.exe -i /Cygwin-Terminal.ico \ > >>>>> --position @3 --position 715,0 --size 80x45 /bin/tcsh & > >>>>> C:/cygwin64/bin/mintty.exe -i /Cygwin-Terminal.ico \ > >>>>> --position @3 --position 715,660 --size 80x24 /bin/tcsh & > >>>>> > >>>>> Within the last 6 months or so, about 2-3 of them would hang and > >>>>> either mintty/tcsh would not start. I put a "sleep 1" in between each > >>>>> invocation and that seemed to take care of it. > >>>>> > >>>>> With the latest cygwin update, about 8 of them just hang even with > >>>>> the sleep 1. I put in a "sleep 2", and now everything is coming up > >>>>> again. > >>>>> > >>>>> Not sure if this is a mintty or tcsh issue, but just wondering if > >>>>> others are seeing this before I start trying to debug this. > >>>> I can reproduce such behaviour with /bin/bash (easy cross-check), and > >>>> in fact the shell is running in that case (easy test via `echo > > >>>> .log`), so I have a vague and unpleasant suspicion it might in fact be > >>>> related to mintty although I have no idea how that would happen. To be > >>>> analysed. > >>> When in this state, on the pty from which mintty receives child process > >>> output, select() does not report a ready for reading condition; > >>> could it > >>> be related to the recent poll/select patch? I could not reproduce it in > >>> cygwin 3.0.7. > >> for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do > >> mintty  -i /Cygwin-Terminal.ico  --position @3 --position 120,$i > >> --size 80x24 /bin/bash & done > >> > >> This does not fail for me.  Nor does it fail from cmd or powershell > >> using a script. > >> > >> I tried 3.1.4 and 3.1.6 on Windows 10.  I tried up to 100 instances > >> of of mintty... > > Thanks for testing. It is in fact hard to reproduce, maybe also > > depending on system load (speculating). > > I could reproduce one case of one of three terminals being > > unresponsive also with xterm. > And it also happens if I drop select() from mintty (and use just > non-blocking read()). > > Does anybody familiar with pty/select or recent changes have any idea? I looked into this problem. After much struggle, I think I have found a workaround for this issue. I am not sure why this solves the issue at all, however, this works for me. Could you please test a patch attached? -- Takashi Yano --Multipart=_Tue__11_Aug_2020_13_59_48_+0900_vwm=him6qccruPyq Content-Type: application/octet-stream; name="0001-Cygwin-pty-Add-a-workaround-for-issue-of-starting-a-.patch" Content-Disposition: attachment; filename="0001-Cygwin-pty-Add-a-workaround-for-issue-of-starting-a-.patch" Content-Transfer-Encoding: base64 RnJvbSBjYzQ1MTY0OGJiYzdmMzk1ZmEwMGNiMmI5NzM1MWQxNTEzODI3ZjgyIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBUYWthc2hpIFlhbm8gPHRha2FzaGkueWFub0BuaWZ0eS5uZS5q cD4KRGF0ZTogVHVlLCAxMSBBdWcgMjAyMCAxMzoxNjo1MiArMDkwMApTdWJqZWN0OiBbUEFUQ0hd IEN5Z3dpbjogcHR5OiBBZGQgYSB3b3JrYXJvdW5kIGZvciBpc3N1ZSBvZiBzdGFydGluZyBhIGxv dCBvZgogbWludHR5LgoKLSBJZiBhIGxvdCBvZiBtaW50dHkgYXJlIHN0YXJ0ZWQgaW4gYSBzaG9y dCB0aW1lIGZyb20gYSBtaW50dHksIHNvbWU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