delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/03/18/08:16:15

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9F8F33853804
Authentication-Results: sourceware.org;
dmarc=fail (p=none dis=none) header.from=nifty.ne.jp
Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp
DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com 22ICFKWY003251
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp;
s=dec2015msa; t=1647605720;
bh=mTGKjKytQzDNvzmZY2wwJSgPRkAKDf+lV71VcggEzbE=;
h=Date:From:To:Cc:Subject:In-Reply-To:References:From;
b=EmFBP9JEKrgwKq8d3w3Cko7mEWcnRbgr0wN8v1jkd0JvJhIAiyVeqBCd51Px5xyAw
C1dXm0H1zCUzaR/uILG82g0KTaDkE0FJYKUiuvKRPuzgPJOHXTLdx02cH0aINzVJop
vgRf++Idu+9DwMG6KiGh0GtljtWziAQ94MY+unr00oSCp3DsMO85QtnJD0PeJ654wE
IiLrIJiBB7REgnBvrcCpaoOT/u2qXc06NwPqy/ITXannw4cdGHbeWmnN4Fwl6ko+0c
AxXQDCm5W4+5ilv4fi7SaBRc+G5FR+qcMIvlWHHOEOZckbdLHiVUci7yHHrKIWtCnw
Ks+ATscphjMeg==
X-Nifty-SrcIP: [119.150.36.16]
Date: Fri, 18 Mar 2022 21:15:22 +0900
From: Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>
To: cygwin AT cygwin DOT com
Subject: Re: Typed characters are mis-ordered when CPU usage is high
Message-Id: <20220318211522.936158f91219816ca5c707e7@nifty.ne.jp>
In-Reply-To: <CAGHpTBLYStvKSOc8JZtCdTcziLam=xzO5eGs+VF0LGXJM8dG3A@mail.gmail.com>
References: <CAGHpTBKbqxWQ+WOc=UZH1a155gHhNc4ogVE0sP=rCw7q5xoNpQ AT mail DOT gmail DOT com>
<20220227235303 DOT 5d6239724ed83b145772134b AT nifty DOT ne DOT jp>
<20220302081259 DOT 2a7e522ef1a9e3e6da0aa259 AT nifty DOT ne DOT jp>
<CAGHpTBLc9waVzjKWb84C5KS+s9uKENrOMAxxfBBrvPR-zKKtPQ AT mail DOT gmail DOT com>
<20220303090208 DOT 4a04e35756b7868fe9b4701d AT nifty DOT ne DOT jp>
<CAGHpTBKU5XQJ6mjsvb94LnbJb5xj3uoRMtt3KgsMx1NjpM5hSg AT mail DOT gmail DOT com>
<20220312063625 DOT 9ca3d42d4e2e941a13fa7909 AT nifty DOT ne DOT jp>
<CAGHpTBLe0D9gQaK=4A91w5eravsygpWe001DhcB=hhrcLx6YWA AT mail DOT gmail DOT com>
<20220318132335 DOT d5635fe9fc782ed53bddf7bc AT nifty DOT ne DOT jp>
<20220318142243 DOT 1751c742ebaae47e8fba9b47 AT nifty DOT ne DOT jp>
<CAGHpTBLRzXpg77FjxT6OQPrC+12k1VYd-r-wNryEC0DZiYdQfw AT mail DOT gmail DOT com>
<20220318153058 DOT 22d217eea1bb746e709da555 AT nifty DOT ne DOT jp>
<CAGHpTBKMxgUdbucTKzVzthUB4u_F5P=sOrjVnjPz-kd8YLumSA AT mail DOT gmail DOT com>
<CAGHpTBLYStvKSOc8JZtCdTcziLam=xzO5eGs+VF0LGXJM8dG3A AT mail DOT gmail DOT com>
X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Mime-Version: 1.0
X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE,
SPF_HELO_NONE, SPF_PASS, TXREP,
T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Cc: Orgad Shaneh <orgads AT gmail DOT com>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

This is a multi-part message in MIME format.

--Multipart=_Fri__18_Mar_2022_21_15_22_+0900_oDCDPA9671h3SKbq
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

On Fri, 18 Mar 2022 13:21:00 +0200
Orgad Shaneh wrote:
> > Git for Windows
> 
> Were you able to reproduce?
> 
> I found an easier way to reproduce, which works almost every time.
> 
> It still happens only on Git Bash, and not on MSYS2 MINGW64, although
> I use the same dll in both. I have no idea why there's a difference.
> :/
> 
> I run Windows Terminal, but it reproduces also in cmd, as you tried.
> 
> 1. In Control Panel -> Keyboard, set Repeat delay to shortest and
> Repeat rate to fastest.
> 2. In msys2-runtime run git fetch
> 3. Type git and press and hold q

Thanks. I can reproduce the issue. I think I found the cause.
The two unexpected things happen.

(1) wVirtualKeyCode and wVirtualScanCode of readback key event may
    be null'ed even if they are not zero on WriteConsoleInputW().
    Therefore, memcmp() report the event is not equal.
(2) WriteConsoleInputW() may not be atomic. The event sequence which
    is written by WriteConsoleInputW() may be inserted by key input
    in the middle of the sequence.

A patch for these issues is attached. Could you please test?

-- 
Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>

--Multipart=_Fri__18_Mar_2022_21_15_22_+0900_oDCDPA9671h3SKbq
Content-Type: application/octet-stream;
 name="prevent-swap.patch"
Content-Disposition: attachment;
 filename="prevent-swap.patch"
Content-Transfer-Encoding: base64

ZGlmZiAtLWdpdCBhL3dpbnN1cC9jeWd3aW4vZmhhbmRsZXJfY29uc29sZS5jYyBiL3dpbnN1cC9j
eWd3aW4vZmhhbmRsZXJfY29uc29sZS5jYwppbmRleCBhZGFjNjllODkuLjQ0MzI4Y2I2ZiAxMDA2
NDQKLS0tIGEvd2luc3VwL2N5Z3dpbi9maGFuZGxlcl9jb25zb2xlLmNjCisrKyBiL3dpbnN1cC9j
eWd3aW4vZmhhbmRsZXJfY29uc29sZS5jYwpAQCAtMTgwLDYgKzE4MCwyNyBAQCBjb25zX21hc3Rl
cl90aHJlYWQgKFZPSUQgKmFyZykKICAgcmV0dXJuIDA7CiB9CiAKK3N0YXRpYyBpbmxpbmUgYm9v
bAoraW5yZWNfZXEgKGNvbnN0IElOUFVUX1JFQ09SRCAqYSwgY29uc3QgSU5QVVRfUkVDT1JEICpi
LCBEV09SRCBuKQoreworICBmb3IgKERXT1JEIGkgPSAwOyBpIDwgbjsgaSsrKQorICAgIHsKKyAg
ICAgIGlmIChhW2ldLkV2ZW50VHlwZSA9PSBLRVlfRVZFTlQgJiYgYltpXS5FdmVudFR5cGUgPT0g
S0VZX0VWRU5UKQorCXsgLyogd1ZpcnR1YWxLZXlDb2RlIGFuZCB3VmlydHVhbFNjYW5Db2RlIG9m
IHRoZSByZWFkYmFjaworCSAgICAga2V5IGV2ZW50IG1heSBiZSBkaWZmZXJlbnQgZnJvbSB0aGF0
IG9mIHdyaXR0ZW4gZXZlbnQuICovCisJICBjb25zdCBLRVlfRVZFTlRfUkVDT1JEICphayA9ICZh
W2ldLkV2ZW50LktleUV2ZW50OworCSAgY29uc3QgS0VZX0VWRU5UX1JFQ09SRCAqYmsgPSAmYltp
XS5FdmVudC5LZXlFdmVudDsKKwkgIGlmIChhay0+YktleURvd24gIT0gYmstPmJLZX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G06OmJ5dGVzIChuIC0gKG9mc3QgKyB0b3RhbF9yZWFkKSkpOwotCQkgICAgdG90YWxfcmVh
ZCA9IG47Ci0JCSAgICBicmVhazsKKwkJICAgIGlmICh0b3RhbF9yZWFkICsgaiAtIGkgPj0gbikK
KwkJICAgICAgeyAvKiBTb21ldGhpbmcgaXMgd3JvbmcuLi4gR2l2aW5nIHVwLiAqLworCQkJV3Jp
dGVDb25zb2xlSW5wdXRXIChwLT5pbnB1dF9oYW5kbGUsIHRtcCwgbiwgJm4pOworCQkJZ290byBz
a2lwX3dyaXRlYmFjazsKKwkJICAgICAgfQorCQkgICAgaW5wdXRfcmVjW3RvdGFsX3JlYWQgKyBq
IC0gaV0gPSB0bXBbal07CiAJCSAgfQotCSAgICAgIGlmIChvZnN0ID4gaW5jcikKLQkJYnJlYWs7
IC8qIFdyaXRlYmFjayB3YXMgbm90IGF0b21pYy4gT3Igc29tZW9uZSBoYXMgcmVhZAotCQkJICBp
bnB1dCB3aXRob3V0IGFjcXVpcmluZyBpbnB1dF9tdXRleC4KLQkJCSAgR2l2aW5nIHVwIGJlY2F1
c2UgaGFyZCB0byBmaXguICovCisJCWVsc2UKKwkJICBpKys7CisJICAgICAgdG90YWxfcmVhZCA9
IG47CiAJICAgIH0KIAkgIHdoaWxlICh0cnVlKTsKIAl9Cg==

--Multipart=_Fri__18_Mar_2022_21_15_22_+0900_oDCDPA9671h3SKbq
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


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

--Multipart=_Fri__18_Mar_2022_21_15_22_+0900_oDCDPA9671h3SKbq--

- Raw text -


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