X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4ACB33856DDE
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1689834840;
	bh=MFHrWqS+5sm+2fxAXTr55CsT5Qk7B4ofOYk5Z2KXN9Q=;
	h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:
	 List-Help:List-Subscribe:From:Reply-To:From;
	b=FiVKNgSpostREkG7589mLhU//bVAAHiijWb2C0LI+xzEfm8k90M7up6w7N22FEyQZ
	 JF23rGygFl7myQxWCs4mZLdxZYYYHIRHB4HahHrws/g9bVWVRXI+yZHSCVMp3lrMf2
	 X/x48PE0uooPzdY5zNcLBGT3B1+Nr7EPOqasstao=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CAE053856DE2
Message-ID: <6f0bfdf8-a557-0540-0367-6846406f941d@towo.net>
Date: Thu, 20 Jul 2023 08:33:41 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
 Thunderbird/102.13.0
To: cygwin@cygwin.com
Subject: Rare character glitch in pty?
X-Provags-ID: V03:K1:oiUqOCSrcDHS2AIShuVgZRW+Y+7ygk9Yb+PILttr5ckFuhwW66r
 re43wBA2YlWB32ztga2cTurJGCIr2iMnLHRDiZgABSwOkcjRJnYQxAPmyOWKyreKHuXu4ui
 gXxPfpI0vSm99eBrLdcPDxJ4Yix9n2F7pECXAY4KjMPXfRxs45r46/KE6v3cJ5ZIlhI1gg/
 7BD7hqCF/DbNNJrhYGtcg==
UI-OutboundReport: notjunk:1;M01:P0:cwl+nfvXY/I=;aflOXzqCSoiPIDEfOSCgyIHrLkv
 zQXUlIAX9Ttn7T3/IRTr4Kh5shbHlA3oEBsjyPZSyFCa+RGmitGvq4p9ad14cKp0QIB+Ih5V1
 IkBWS8uoG1sovksPy2D9L5qM2ujE/2uSJRMvEPHDz1GMGhCstOr/czUb9NgBTjodmRQCmlK/e
 bCAFfXAXP6/jpOpgEEcn5IGzkQLCzOck4Tls9idtcvfCcLVeLPd2xyfxDgnee6EvAvMGNeInY
 Wugaq2W8yKuA2681U+2EGxNw527ChlePAgG0nAbOfYjJXB6uyuH+aD8pqTYf2D9mYuBonl5my
 6RyPgTnzYmmynfFRFQg4MG5+AH6tGCVUXDqUSnlU+u4p6B+uD24nklD5P/nVqYa4TmCJCJohl
 PrtfE2jxto3sufe5lu6rcXJuIHpHBqB3ssdIxv5a+14OoVWUNTFq+7/Bb83QBNDm6Lo8bA5Pc
 OvWQLGZrEDS0Rz2eSawS9C59sR2faSvR2cmD+Glg7JNhV1C93SwXxowNe+3uR6nqx6CzLBTLf
 p5MOwAyPwLJcGfy3VF/lCTNH7+x/JJSBkDO6OGJP6ezl4bTU2B6kTmUfiKAYUIfudi30LjOai
 u/1zIGNqfbU+1EjSUmCERdF0rjGeMg+mXCbjXeGOO3Ms98FmVHSZ9iLxAcy0GGatTZ7eAJJaC
 mljpvfnSZMwrbQQZujygHZVPSiaz1d6thUADAZfZEA==
X-Spam-Status: No, score=1.5 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS,
 RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,
 RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP,
 T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6
X-Spam-Level: *
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
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>
From: Thomas Wolff via Cygwin <cygwin@cygwin.com>
Reply-To: Thomas Wolff <towo@towo.net>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>

There was a report that on switching terminal windows with the mouse,
focus event reports (as enabled with ESC[?1004h) would sometimes get 
mangled.
This is further described in issue reports to mintty/wsltty 
(https://github.com/mintty/wsltty/issues/335) and also to tmux 
(https://github.com/tmux/tmux/issues/3601).

I could reproduce the issue without either of tmux or WSL. However, it 
happens only once in a few hundred instances:
The escape sequence is changed so that the initial ESC is replaced by 
one of the two subsequent characters, so instead of ESC[O, either of [[O 
or sometimes O[O would be sent to the foreground application.

I traced the issue down to the pty that connects mintty and its client 
application, verified that the correct sequence is passed into write() 
at the pty and the mangled sequence appears at read() in the client 
process. In addition to a minimised test program that behaves like `cat 
-v`, I also also put the test output directly into the client process 
within the mintty code.
This leaves the only conclusion that the issue must be happening somehow 
within pty handling, maybe in the context of some timing condition or 
Windows messages being passed to mintty.
Anyhow, I was about to prepare testing with older mintty versions, in 
case I overlooked something, when the OP reported that the issue does 
not happen with cygwin 3.2.0.
Is there any recent change that could possibly cause such weird behaviour?
Thomas

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