X-Recipient: archive-cygwin@delorie.com
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C2E163858D39
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 2230TUR3019094
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp;
 s=dec2015msa; t=1646267370;
 bh=5iIgxSd8tdHZsYNJUr0/PhDQXtmFu6G6DTyvsAbNdo8=;
 h=Date:From:To:Cc:Subject:In-Reply-To:References:From;
 b=W7Jm/SUIcaAvFMxXwzuR3MDP7iPJwCYLFSXtY7eO5LQmvtltblXpvZ5jaY6H4kFZj
 Y6w71FPwn4vF260HXFwhB/GEfvyFCFiQ34dlJku1EH5ltb8hUVvqbA+S7KaZ784f3j
 qvpH/jYQPpbi9SGR4Eufxo8eQ920xRiILGdbe9azhzxaSpU3PhKmfzi/VKsKm82PDQ
 Pvdmt7jvX5FNO6ZrRKnALnlMz0se/FDvcdcoi0Ygf+L567ECVg1+b6IUJryw37HDS0
 t572TMG09gQwazqZsOAKa3pvinWRqRzmGwht2QfM358WfKm0UASkh8vQWQrW3UJgpB
 1ntr7xVwav85Q==
X-Nifty-SrcIP: [119.150.36.16]
Date: Thu, 3 Mar 2022 09:29:38 +0900
From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin@cygwin.com
Subject: Re: Typed characters are mis-ordered when CPU usage is high
Message-Id: <20220303092938.7b19d0eb94d97d262f6d039e@nifty.ne.jp>
In-Reply-To: <80097aaab50d22d359e9ce620beb3f97@mail.kylheku.com>
References: <CAGHpTBKbqxWQ+WOc=UZH1a155gHhNc4ogVE0sP=rCw7q5xoNpQ@mail.gmail.com>
 <20220227235303.5d6239724ed83b145772134b@nifty.ne.jp>
 <80097aaab50d22d359e9ce620beb3f97@mail.kylheku.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@cygwin.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
Cc: orgads@gmail.com
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cygwin-bounces+archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>

On Wed, 02 Mar 2022 12:28:47 -0800
"Kaz Kylheku wrote:
> On 2022-02-27 06:53, Takashi Yano wrote:
> > I think this is due to a bug which I recently fixed.
> > https://cygwin.com/pipermail/cygwin-patches/2022q1/011791.html
> 
> Was that upstreamed? Sorry to be a pain, but something in the
> log message about the cause and the fix (not just the manifested
> issue being addressed) would be good.
> 
> Reversed characters might mess not only with the user's input,
> but with input coming from terminal emulation, like escape
> sequences, which may be a worse problem.

What do you mean by upstream? The patch was applied the current
cygwin git head (master) and cygwin-3_3-branch. This bug only
affected to the key typed input (user key typing) in console
(e.g. command prompt or Windows Termainal).

If you mean output to the terminal by "input coming from terminal
emulation", that is not affected. If you mean returned escape
sequence such as 'ESC [ 24;1R' against 'ESC [6n', this should not
be affected as well.

The problem was that the console input buffer:
https://docs.microsoft.com/en-us/windows/console/console-input-buffer
could be messed up by the conflict between WriteConsoleInputW()
called in console code (cons_master_thread()) and the keyboard
events comes from user key typing. This has been fixed by checking
the order of the input events in console input buffer after
WriteConsoleInputW() and reordering that if the older events are
placed after newer events.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

-- 
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
