GNU bug report logs - #7117
23.2.2 mangles terminal escape sequences

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Ryan Johnson <ryanjohn@HIDDEN>; dated Mon, 27 Sep 2010 12:08:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 7117 <at> debbugs.gnu.org:


Received: (at 7117) by debbugs.gnu.org; 30 Sep 2010 16:09:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 30 12:09:07 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1P1Lgx-0001k4-5X
	for submit <at> debbugs.gnu.org; Thu, 30 Sep 2010 12:09:07 -0400
Received: from bache.ece.cmu.edu ([128.2.129.23])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <ryanjohn@HIDDEN>) id 1P1Lgu-0001ji-N2
	for 7117 <at> debbugs.gnu.org; Thu, 30 Sep 2010 12:09:05 -0400
Received: from [128.178.77.144] (diaspc12.epfl.ch [128.178.77.144])
	by bache.ece.cmu.edu (Postfix) with ESMTP id 032AF194;
	Thu, 30 Sep 2010 12:11:59 -0400 (EDT)
Message-ID: <4CA4B6CE.7060101@HIDDEN>
Date: Thu, 30 Sep 2010 18:11:58 +0200
From: Ryan Johnson <ryanjohn@HIDDEN>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
	rv:1.9.2.8) Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2
MIME-Version: 1.0
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#7117: 23.2.2 mangles terminal escape sequences
References: <4CA089B5.80601@HIDDEN>
	<jwv4odaykp4.fsf-monnier+emacs@HIDDEN>
	<4CA174DA.701@HIDDEN> <4CA47684.5020806@HIDDEN>
	<4CA4A10B.8050201@HIDDEN> <837hi3p994.fsf@HIDDEN>
	<4CA4A948.70907@HIDDEN> <8362xnp76n.fsf@HIDDEN>
In-Reply-To: <8362xnp76n.fsf@HIDDEN>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -6.3 (------)
X-Debbugs-Envelope-To: 7117
Cc: monnier@HIDDEN, 7117 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.4 (------)

  On 9/30/2010 5:44 PM, Eli Zaretskii wrote:
>> Date: Thu, 30 Sep 2010 17:14:16 +0200
>> From: Ryan Johnson<ryanjohn@HIDDEN>
>> CC: monnier@HIDDEN, 7117 <at> debbugs.gnu.org
>>
>>>>    From the above, it seems that scrolling past beginning or end of buffer
>>>> triggers an error, which I guess is somewhat justifiable.
>>> Indeed.  Perhaps we need some infrastructure to ignore errors in this
>>> case (I assume `ignore-errors' won't help).  Or maybe we should allow
>>> not to discard input when we signal an error.  Or maybe discard-input
>>> should be smarter, and not discard partial escape sequences?
>> One thing I don't get is, I've been using emacs over painfully slow ssh
>> connections for literally years -- sometimes slow enough that keystrokes
>> take visible time to echo. This was never really an issue before.
> What would you expect to see, that would cause you think it was "an
> issue"?  When Emacs is keyboard-driven, typing text and scrolling
> commands seldom happen in such a quick succession that hitting end of
> buffer while scrolling would discard text you typed meanwhile.  And
> even if it did, how would you know for sure you actually typed it?
It's not just keyboard driven. It's a mouse-enabled terminal and the 
mouse click/wheel actions cause the issues (each one generates a burst 
of 6-12 characters). As you say, I don't think I've ever seen this 
happen with keyboard input; pasting commands from a remote X clipboard 
might have a similar effect, but I've never tried.

In the past, scrolling once or twice past buffer begin/end wasn't 
guaranteed to dump garbage. It would just beep/flash most of the time, 
and the slow network connection didn't seem to make it worse. Now, if 
I'm not on intranet, virtually every scroll past-end will dump garbage 
somewhere.

Also, the problem I hit this morning was not related to fast 
typing/clicking over a slow connection. I was doing an ediff-files 
session, and about every other time I clicked on a buffer to edit a 
conflict, emacs would reward me with a mangled escape code... sometimes 
where point had been and sometimes where it ended up. I wasn't typing 
fast or clicking madly -- it was more like "a n n n n b n n <stare a 
while> <click> <grumble> <clean up mess>"

The latter problem went away once I got to work and had a fast network; 
and the former happens much less frequently here (unless I give the 
wheel a really good spin, but that's understandable).

Ryan






Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#7117; Package emacs. Full text available.

Message received at 7117 <at> debbugs.gnu.org:


Received: (at 7117) by debbugs.gnu.org; 30 Sep 2010 15:41:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 30 11:41:38 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1P1LGL-0001XH-OW
	for submit <at> debbugs.gnu.org; Thu, 30 Sep 2010 11:41:38 -0400
Received: from mtaout22.012.net.il ([80.179.55.172])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <eliz@HIDDEN>) id 1P1LGJ-0001XB-OP
	for 7117 <at> debbugs.gnu.org; Thu, 30 Sep 2010 11:41:36 -0400
Received: from conversion-daemon.a-mtaout22.012.net.il by
	a-mtaout22.012.net.il (HyperSendmail v2007.08) id
	<0L9K00A00H0VLA00@HIDDEN> for
	7117 <at> debbugs.gnu.org; Thu, 30 Sep 2010 17:44:29 +0200 (IST)
Received: from HOME-C4E4A596F7 ([77.126.123.60]) by a-mtaout22.012.net.il
	(HyperSendmail v2007.08) with ESMTPA id
	<0L9K009AWH24NAE0@HIDDEN>;
	Thu, 30 Sep 2010 17:44:29 +0200 (IST)
Date: Thu, 30 Sep 2010 17:44:32 +0200
From: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#7117: 23.2.2 mangles terminal escape sequences
In-reply-to: <4CA4A948.70907@HIDDEN>
X-012-Sender: halo1@HIDDEN
To: Ryan Johnson <ryanjohn@HIDDEN>
Message-id: <8362xnp76n.fsf@HIDDEN>
References: <4CA089B5.80601@HIDDEN>
	<jwv4odaykp4.fsf-monnier+emacs@HIDDEN>
	<4CA174DA.701@HIDDEN> <4CA47684.5020806@HIDDEN>
	<4CA4A10B.8050201@HIDDEN> <837hi3p994.fsf@HIDDEN>
	<4CA4A948.70907@HIDDEN>
X-Spam-Score: -2.1 (--)
X-Debbugs-Envelope-To: 7117
Cc: monnier@HIDDEN, 7117 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
Reply-To: Eli Zaretskii <eliz@HIDDEN>
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.1 (--)

> Date: Thu, 30 Sep 2010 17:14:16 +0200
> From: Ryan Johnson <ryanjohn@HIDDEN>
> CC: monnier@HIDDEN, 7117 <at> debbugs.gnu.org
> 
> >>  From the above, it seems that scrolling past beginning or end of buffer
> >> triggers an error, which I guess is somewhat justifiable.
> > Indeed.  Perhaps we need some infrastructure to ignore errors in this
> > case (I assume `ignore-errors' won't help).  Or maybe we should allow
> > not to discard input when we signal an error.  Or maybe discard-input
> > should be smarter, and not discard partial escape sequences?
> One thing I don't get is, I've been using emacs over painfully slow ssh 
> connections for literally years -- sometimes slow enough that keystrokes 
> take visible time to echo. This was never really an issue before.

What would you expect to see, that would cause you think it was "an
issue"?  When Emacs is keyboard-driven, typing text and scrolling
commands seldom happen in such a quick succession that hitting end of
buffer while scrolling would discard text you typed meanwhile.  And
even if it did, how would you know for sure you actually typed it?




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#7117; Package emacs. Full text available.

Message received at 7117 <at> debbugs.gnu.org:


Received: (at 7117) by debbugs.gnu.org; 30 Sep 2010 15:11:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 30 11:11:26 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1P1Kn8-0001KS-KO
	for submit <at> debbugs.gnu.org; Thu, 30 Sep 2010 11:11:26 -0400
Received: from bache.ece.cmu.edu ([128.2.129.23])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <ryanjohn@HIDDEN>) id 1P1Kn5-0001KN-Hm
	for 7117 <at> debbugs.gnu.org; Thu, 30 Sep 2010 11:11:24 -0400
Received: from [128.178.77.144] (diaspc12.epfl.ch [128.178.77.144])
	by bache.ece.cmu.edu (Postfix) with ESMTP id E5BCF1A1;
	Thu, 30 Sep 2010 11:14:18 -0400 (EDT)
Message-ID: <4CA4A948.70907@HIDDEN>
Date: Thu, 30 Sep 2010 17:14:16 +0200
From: Ryan Johnson <ryanjohn@HIDDEN>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
	rv:1.9.2.8) Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2
MIME-Version: 1.0
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#7117: 23.2.2 mangles terminal escape sequences
References: <4CA089B5.80601@HIDDEN>
	<jwv4odaykp4.fsf-monnier+emacs@HIDDEN>
	<4CA174DA.701@HIDDEN> <4CA47684.5020806@HIDDEN>
	<4CA4A10B.8050201@HIDDEN> <837hi3p994.fsf@HIDDEN>
In-Reply-To: <837hi3p994.fsf@HIDDEN>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -6.2 (------)
X-Debbugs-Envelope-To: 7117
Cc: monnier@HIDDEN, 7117 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.3 (------)

  On 9/30/2010 4:59 PM, Eli Zaretskii wrote:
>> From: Ryan Johnson<ryanjohn@HIDDEN>
>> Cc: 7117 <at> debbugs.gnu.org
>>
>> At this point the symptom is easy enough to understand: sometimes
>> discard-input gets unlucky and chops the front off of a partly-arrived
>> escape sequence.
>>
>> The real question is, why would the command loop encounter errors and
>> need to discard input at all?
>>     [1] _longjmp()
>> =>[2] unwind_to_catch()
>>     [3] Fsignal()
>>     [4] xsignal()
>>     [5] xsignal0()
>>     [6] window_scroll()
> The only calls to xsignal0 I see in window_scroll (or, rather, in its
> subroutines) is to signal Qbeginning_of_buffer or Qend_of_buffer.
>
>>  From the above, it seems that scrolling past beginning or end of buffer
>> triggers an error, which I guess is somewhat justifiable.
> Indeed.  Perhaps we need some infrastructure to ignore errors in this
> case (I assume `ignore-errors' won't help).  Or maybe we should allow
> not to discard input when we signal an error.  Or maybe discard-input
> should be smarter, and not discard partial escape sequences?
One thing I don't get is, I've been using emacs over painfully slow ssh 
connections for literally years -- sometimes slow enough that keystrokes 
take visible time to echo. This was never really an issue before. In 
retrospect, it did pop up occasionally all along, but it was infrequent 
enough to hide in the shadow of xterm mouse escape sequences confusing 
emacs for x>95. Now it interferes with normal work. Is there some change 
that would have done this? I'm using the same bad internet connection as 
when I had emacs-22...

>> However, on a
>> very slow connection this morning mouse-clicking between or even within
>> buffers caused problems. Unfortunately, setting debug-on-error doesn't
>> seem to catch errors generated from C code.
>>
>> I could try to break on longjmp over another slow connection, but with
>> the number of times it gets called for other reasons this would be slow
>> going...
>>
>> Ideas?
> You could put a breakpoint in Fsignal, and see if the problems with
> mouse-clicking within buffers is also caused by signaling an error.
I'll try that next time it becomes annoying (it's hit-and-miss...)

Ryan





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#7117; Package emacs. Full text available.

Message received at 7117 <at> debbugs.gnu.org:


Received: (at 7117) by debbugs.gnu.org; 30 Sep 2010 14:57:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 30 10:57:46 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1P1KZq-0001Dm-Gp
	for submit <at> debbugs.gnu.org; Thu, 30 Sep 2010 10:57:46 -0400
Received: from mtaout22.012.net.il ([80.179.55.172])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <eliz@HIDDEN>) id 1P1KZm-0001Dg-MR
	for 7117 <at> debbugs.gnu.org; Thu, 30 Sep 2010 10:57:40 -0400
Received: from conversion-daemon.a-mtaout22.012.net.il by
	a-mtaout22.012.net.il (HyperSendmail v2007.08) id
	<0L9K00A00EQM2U00@HIDDEN> for
	7117 <at> debbugs.gnu.org; Thu, 30 Sep 2010 16:59:50 +0200 (IST)
Received: from HOME-C4E4A596F7 ([77.126.123.60]) by a-mtaout22.012.net.il
	(HyperSendmail v2007.08) with ESMTPA id
	<0L9K009LJEZNNA80@HIDDEN>;
	Thu, 30 Sep 2010 16:59:49 +0200 (IST)
Date: Thu, 30 Sep 2010 16:59:51 +0200
From: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#7117: 23.2.2 mangles terminal escape sequences
In-reply-to: <4CA4A10B.8050201@HIDDEN>
X-012-Sender: halo1@HIDDEN
To: Ryan Johnson <ryanjohn@HIDDEN>
Message-id: <837hi3p994.fsf@HIDDEN>
References: <4CA089B5.80601@HIDDEN>
	<jwv4odaykp4.fsf-monnier+emacs@HIDDEN>
	<4CA174DA.701@HIDDEN> <4CA47684.5020806@HIDDEN>
	<4CA4A10B.8050201@HIDDEN>
X-Spam-Score: -2.1 (--)
X-Debbugs-Envelope-To: 7117
Cc: monnier@HIDDEN, 7117 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
Reply-To: Eli Zaretskii <eliz@HIDDEN>
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.1 (--)

> From: Ryan Johnson <ryanjohn@HIDDEN>
> Cc: 7117 <at> debbugs.gnu.org
> 
> At this point the symptom is easy enough to understand: sometimes 
> discard-input gets unlucky and chops the front off of a partly-arrived 
> escape sequence.
> 
> The real question is, why would the command loop encounter errors and 
> need to discard input at all?
>    [1] _longjmp()
> =>[2] unwind_to_catch()
>    [3] Fsignal()
>    [4] xsignal()
>    [5] xsignal0()
>    [6] window_scroll()

The only calls to xsignal0 I see in window_scroll (or, rather, in its
subroutines) is to signal Qbeginning_of_buffer or Qend_of_buffer.

> From the above, it seems that scrolling past beginning or end of buffer 
> triggers an error, which I guess is somewhat justifiable.

Indeed.  Perhaps we need some infrastructure to ignore errors in this
case (I assume `ignore-errors' won't help).  Or maybe we should allow
not to discard input when we signal an error.  Or maybe discard-input
should be smarter, and not discard partial escape sequences?

> However, on a 
> very slow connection this morning mouse-clicking between or even within 
> buffers caused problems. Unfortunately, setting debug-on-error doesn't 
> seem to catch errors generated from C code.
> 
> I could try to break on longjmp over another slow connection, but with 
> the number of times it gets called for other reasons this would be slow 
> going...
> 
> Ideas?

You could put a breakpoint in Fsignal, and see if the problems with
mouse-clicking within buffers is also caused by signaling an error.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#7117; Package emacs. Full text available.

Message received at 7117 <at> debbugs.gnu.org:


Received: (at 7117) by debbugs.gnu.org; 30 Sep 2010 14:36:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 30 10:36:21 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1P1KFA-00013y-Td
	for submit <at> debbugs.gnu.org; Thu, 30 Sep 2010 10:36:21 -0400
Received: from bache.ece.cmu.edu ([128.2.129.23])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <ryanjohn@HIDDEN>) id 1P1KF7-00013r-Du
	for 7117 <at> debbugs.gnu.org; Thu, 30 Sep 2010 10:36:18 -0400
Received: from [128.178.77.144] (diaspc12.epfl.ch [128.178.77.144])
	by bache.ece.cmu.edu (Postfix) with ESMTP id 5E987192;
	Thu, 30 Sep 2010 10:39:09 -0400 (EDT)
Message-ID: <4CA4A10B.8050201@HIDDEN>
Date: Thu, 30 Sep 2010 16:39:07 +0200
From: Ryan Johnson <ryanjohn@HIDDEN>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
	rv:1.9.2.8) Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2
MIME-Version: 1.0
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#7117: 23.2.2 mangles terminal escape sequences
References: <4CA089B5.80601@HIDDEN>
	<jwv4odaykp4.fsf-monnier+emacs@HIDDEN>
	<4CA174DA.701@HIDDEN> <4CA47684.5020806@HIDDEN>
In-Reply-To: <4CA47684.5020806@HIDDEN>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -6.0 (------)
X-Debbugs-Envelope-To: 7117
Cc: 7117 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.2 (------)

  On 9/30/2010 1:37 PM, Ryan Johnson wrote:
>  On 9/28/2010 6:53 AM, Ryan Johnson wrote:
>>  On 9/27/2010 10:52 PM, Stefan Monnier wrote:
>>>> Steps to reproduce:
>>>>    1. ssh to a machine with emacs-23 installed (I suspect slower
>>>>       networks would expose this more, but the bug bites me even over
>>>>       intranet)
>>>>    2. compile tee-input.c (see below) into a shared library (on 
>>>> solaris:
>>>>       `cc -g -G -xcode=pic13 -ldl -hlibtee-input.so tee-input.c -g -o
>>>>       libtee-input.so')
>>>>    3. invoke `LD_PRELOAD=libtee-input.so emacs -nw -Q 2>input.txt'
>>>>    4. M-x xterm-mouse-mode
>>>>    5. flick the mouse scroll wheel hard, so it generates many ticks in
>>>>       quick succession (note the garbage that results)
>>>>    6. M-x show-lossage (note the mangled escape sequences)
>>>>    7. C-x C-c
>>>>    8. Examine input.txt (note the intact escape sequences)
>>> Does (set-keyboard-coding-system 'binary) circumvent the problem?
>> No. In fact, the solaris machine which I ran the example on defaults 
>> to `no-conversion' (an alias of binary iirc) for some reason. Sorry, 
>> I forgot to mention before.
>>
>> This matches my expectations, since bug #6920 arises before any 
>> coding system touches the input.
> Any hints on where the problem might lurk? I poked around a little but 
> without luck -- the functions that power read-char are many hundreds 
> of lines long and seem to weave between lisp and C at regular 
> intervals. I'm willing to go source diving but it's a bit daunting to 
> wade into the C code again without a starting reference.
OK, I bit the bullet and fired up a debugger. I've narrowed down the 
problem some.

In keyboard.c, all keyboard input is buffered in kbd_buffer, which is a 
circular buffer with tail kbd_fetch_ptr. In all cases, when a control 
sequence gets mangled it's because kbd_fetch_ptr was incremented by more 
than one slot between iterations of the command loop (often by several 
dozen). However, it turns out that incrementing by more than one slot 
happens quite often and only sometimes exhibits the bug.

More digging shows that multiple increments are due to Fdiscard_input 
being called with the following stack trace:
=>[1] Fdiscard_input(), line 10947 in "keyboard.c"
   [2] cmd_error_internal(data = -1059860928, context = 0xffbfee40 ""), 
line 1301 in "keyboard.c"
   [3] cmd_error(data = -1059860928), line 1234 in "keyboard.c"
   [4] internal_condition_case(bfun = 0x111578 = &command_loop_1(), 
handlers = 1077839640, hfun = 0x109b8c = &cmd_error(register Lisp_Object 
data)), line 1480 in "eval.c"
   [5] command_loop_2(), line 1360 in "keyboard.c"
   [6] internal_catch(tag = 1077836792, func = 0x10283c = 
&command_loop_2(), arg = 1077782856), line 1226 in "eval.c"
   [7] command_loop(), line 1339 in "keyboard.c"
   [8] recursive_edit_1(), line 954 in "keyboard.c"
   [9] Frecursive_edit(), line 1016 in "keyboard.c"
   [10] main(argc = 3, argv = 0xffbff374), line 1833 in "emacs.c"

At this point the symptom is easy enough to understand: sometimes 
discard-input gets unlucky and chops the front off of a partly-arrived 
escape sequence.

The real question is, why would the command loop encounter errors and 
need to discard input at all?
   [1] _longjmp()
=>[2] unwind_to_catch()
   [3] Fsignal()
   [4] xsignal()
   [5] xsignal0()
   [6] window_scroll()
   [7] scroll_command()
   [8] Fscroll_down()
   [9] Ffuncall()
   [10] Feval()
   [11] internal_lisp_condition_case()
   [12] Fbyte_code()
   [13] funcall_lambda()
   [14] Ffuncall()
   [15] Fapply()
   [16] apply1()
   [17] Fcall_interactively()
   [18] Ffuncall()
   [19] call3()
   [20] Fcommand_execute()
   [21] command_loop_1()
   [22] internal_condition_case()
   [23] command_loop_2()
   [24] internal_catch()
   [25] command_loop()
   [26] recursive_edit_1()
   [27] Frecursive_edit()
   [28] main()

 From the above, it seems that scrolling past beginning or end of buffer 
triggers an error, which I guess is somewhat justifiable. However, on a 
very slow connection this morning mouse-clicking between or even within 
buffers caused problems. Unfortunately, setting debug-on-error doesn't 
seem to catch errors generated from C code.

I could try to break on longjmp over another slow connection, but with 
the number of times it gets called for other reasons this would be slow 
going...

Ideas?
Ryan







Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#7117; Package emacs. Full text available.

Message received at 7117 <at> debbugs.gnu.org:


Received: (at 7117) by debbugs.gnu.org; 30 Sep 2010 11:34:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 30 07:34:51 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1P1HPW-0008Dj-Mt
	for submit <at> debbugs.gnu.org; Thu, 30 Sep 2010 07:34:50 -0400
Received: from bache.ece.cmu.edu ([128.2.129.23])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <ryanjohn@HIDDEN>) id 1P1HPU-0008Da-Cf
	for 7117 <at> debbugs.gnu.org; Thu, 30 Sep 2010 07:34:49 -0400
Received: from [128.178.77.144] (diaspc12.epfl.ch [128.178.77.144])
	by bache.ece.cmu.edu (Postfix) with ESMTP id E52CF18B;
	Thu, 30 Sep 2010 07:37:42 -0400 (EDT)
Message-ID: <4CA47684.5020806@HIDDEN>
Date: Thu, 30 Sep 2010 13:37:40 +0200
From: Ryan Johnson <ryanjohn@HIDDEN>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
	rv:1.9.2.8) Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2
MIME-Version: 1.0
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#7117: 23.2.2 mangles terminal escape sequences
References: <4CA089B5.80601@HIDDEN>
	<jwv4odaykp4.fsf-monnier+emacs@HIDDEN> <4CA174DA.701@HIDDEN>
In-Reply-To: <4CA174DA.701@HIDDEN>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 7117
Cc: 7117 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -5.9 (-----)

  On 9/28/2010 6:53 AM, Ryan Johnson wrote:
>  On 9/27/2010 10:52 PM, Stefan Monnier wrote:
>>> Steps to reproduce:
>>>    1. ssh to a machine with emacs-23 installed (I suspect slower
>>>       networks would expose this more, but the bug bites me even over
>>>       intranet)
>>>    2. compile tee-input.c (see below) into a shared library (on 
>>> solaris:
>>>       `cc -g -G -xcode=pic13 -ldl -hlibtee-input.so tee-input.c -g -o
>>>       libtee-input.so')
>>>    3. invoke `LD_PRELOAD=libtee-input.so emacs -nw -Q 2>input.txt'
>>>    4. M-x xterm-mouse-mode
>>>    5. flick the mouse scroll wheel hard, so it generates many ticks in
>>>       quick succession (note the garbage that results)
>>>    6. M-x show-lossage (note the mangled escape sequences)
>>>    7. C-x C-c
>>>    8. Examine input.txt (note the intact escape sequences)
>> Does (set-keyboard-coding-system 'binary) circumvent the problem?
> No. In fact, the solaris machine which I ran the example on defaults 
> to `no-conversion' (an alias of binary iirc) for some reason. Sorry, I 
> forgot to mention before.
>
> This matches my expectations, since bug #6920 arises before any coding 
> system touches the input.
Any hints on where the problem might lurk? I poked around a little but 
without luck -- the functions that power read-char are many hundreds of 
lines long and seem to weave between lisp and C at regular intervals. 
I'm willing to go source diving but it's a bit daunting to wade into the 
C code again without a starting reference.

Thanks,
Ryan





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#7117; Package emacs. Full text available.

Message received at 7117 <at> debbugs.gnu.org:


Received: (at 7117) by debbugs.gnu.org; 28 Sep 2010 04:51:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 28 00:51:03 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1P0S9e-0004ce-G2
	for submit <at> debbugs.gnu.org; Tue, 28 Sep 2010 00:51:02 -0400
Received: from bache.ece.cmu.edu ([128.2.129.23])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <ryanjohn@HIDDEN>) id 1P0S9c-0004cI-Hb
	for 7117 <at> debbugs.gnu.org; Tue, 28 Sep 2010 00:51:01 -0400
Received: from [192.168.0.2] (243-69.2-85.cust.bluewin.ch [85.2.69.243])
	by bache.ece.cmu.edu (Postfix) with ESMTP id 51987B0;
	Tue, 28 Sep 2010 00:53:49 -0400 (EDT)
Message-ID: <4CA174DA.701@HIDDEN>
Date: Tue, 28 Sep 2010 06:53:46 +0200
From: Ryan Johnson <ryanjohn@HIDDEN>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
	rv:1.9.2.8) Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2
MIME-Version: 1.0
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#7117: 23.2.2 mangles terminal escape sequences
References: <4CA089B5.80601@HIDDEN>
	<jwv4odaykp4.fsf-monnier+emacs@HIDDEN>
In-Reply-To: <jwv4odaykp4.fsf-monnier+emacs@HIDDEN>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -6.6 (------)
X-Debbugs-Envelope-To: 7117
Cc: 7117 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.6 (------)

  On 9/27/2010 10:52 PM, Stefan Monnier wrote:
>> Steps to reproduce:
>>    1. ssh to a machine with emacs-23 installed (I suspect slower
>>       networks would expose this more, but the bug bites me even over
>>       intranet)
>>    2. compile tee-input.c (see below) into a shared library (on solaris:
>>       `cc -g -G -xcode=pic13 -ldl -hlibtee-input.so tee-input.c -g -o
>>       libtee-input.so')
>>    3. invoke `LD_PRELOAD=libtee-input.so emacs -nw -Q 2>input.txt'
>>    4. M-x xterm-mouse-mode
>>    5. flick the mouse scroll wheel hard, so it generates many ticks in
>>       quick succession (note the garbage that results)
>>    6. M-x show-lossage (note the mangled escape sequences)
>>    7. C-x C-c
>>    8. Examine input.txt (note the intact escape sequences)
> Does (set-keyboard-coding-system 'binary) circumvent the problem?
No. In fact, the solaris machine which I ran the example on defaults to 
`no-conversion' (an alias of binary iirc) for some reason. Sorry, I 
forgot to mention before.

This matches my expectations, since bug #6920 arises before any coding 
system touches the input.

Ryan





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#7117; Package emacs. Full text available.

Message received at 7117 <at> debbugs.gnu.org:


Received: (at 7117) by debbugs.gnu.org; 27 Sep 2010 20:50:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 27 16:50:00 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1P0Ke8-0001Tf-0k
	for submit <at> debbugs.gnu.org; Mon, 27 Sep 2010 16:50:00 -0400
Received: from fencepost.gnu.org ([140.186.70.10])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <monnier@HIDDEN>) id 1P0Ke4-0001Ta-KM
	for 7117 <at> debbugs.gnu.org; Mon, 27 Sep 2010 16:49:57 -0400
Received: from dyn.83-228-217-009.dsl.vtx.ch ([83.228.217.9]:14169
	helo=fmsmemgm.homelinux.net)
	by fencepost.gnu.org with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.69) (envelope-from <monnier@HIDDEN>)
	id 1P0Kgm-00050K-Km; Mon, 27 Sep 2010 16:52:45 -0400
Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848)
	id 9E60F6611D; Mon, 27 Sep 2010 22:52:44 +0200 (CEST)
From: Stefan Monnier <monnier@HIDDEN>
To: Ryan Johnson <ryanjohn@HIDDEN>
Subject: Re: bug#7117: 23.2.2 mangles terminal escape sequences
Message-ID: <jwv4odaykp4.fsf-monnier+emacs@HIDDEN>
References: <4CA089B5.80601@HIDDEN>
Date: Mon, 27 Sep 2010 22:52:44 +0200
In-Reply-To: <4CA089B5.80601@HIDDEN> (Ryan Johnson's message of "Mon, 27
	Sep 2010 14:10:29 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Score: -4.8 (----)
X-Debbugs-Envelope-To: 7117
Cc: 7117 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -4.9 (----)

> Steps to reproduce:

>   1. ssh to a machine with emacs-23 installed (I suspect slower
>      networks would expose this more, but the bug bites me even over
>      intranet)
>   2. compile tee-input.c (see below) into a shared library (on solaris:
>      `cc -g -G -xcode=pic13 -ldl -hlibtee-input.so tee-input.c -g -o
>      libtee-input.so')
>   3. invoke `LD_PRELOAD=libtee-input.so emacs -nw -Q 2>input.txt'
>   4. M-x xterm-mouse-mode
>   5. flick the mouse scroll wheel hard, so it generates many ticks in
>      quick succession (note the garbage that results)
>   6. M-x show-lossage (note the mangled escape sequences)
>   7. C-x C-c
>   8. Examine input.txt (note the intact escape sequences)

Does (set-keyboard-coding-system 'binary) circumvent the problem?


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#7117; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 27 Sep 2010 12:08:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 27 08:07:59 2010
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1P0CUx-0006AV-03
	for submit <at> debbugs.gnu.org; Mon, 27 Sep 2010 08:07:59 -0400
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <ryanjohn@HIDDEN>) id 1P0CUv-0006AQ-8S
	for submit <at> debbugs.gnu.org; Mon, 27 Sep 2010 08:07:58 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <ryanjohn@HIDDEN>) id 1P0CXb-0004yN-K7
	for submit <at> debbugs.gnu.org; Mon, 27 Sep 2010 08:10:44 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,HTML_MESSAGE,
	RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([199.232.76.165]:56098)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <ryanjohn@HIDDEN>) id 1P0CXb-0004yG-GN
	for submit <at> debbugs.gnu.org; Mon, 27 Sep 2010 08:10:43 -0400
Received: from [140.186.70.92] (port=39872 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1P0CXZ-0001VY-Se
	for bug-gnu-emacs@HIDDEN; Mon, 27 Sep 2010 08:10:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <ryanjohn@HIDDEN>) id 1P0CXV-0004xa-5p
	for bug-gnu-emacs@HIDDEN; Mon, 27 Sep 2010 08:10:41 -0400
Received: from bache.ece.cmu.edu ([128.2.129.23]:58259)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <ryanjohn@HIDDEN>) id 1P0CXV-0004xD-2E
	for bug-gnu-emacs@HIDDEN; Mon, 27 Sep 2010 08:10:37 -0400
Received: from [128.178.77.144] (diaspc12.epfl.ch [128.178.77.144])
	by bache.ece.cmu.edu (Postfix) with ESMTP id 3B37BA2
	for <bug-gnu-emacs@HIDDEN>; Mon, 27 Sep 2010 08:10:34 -0400 (EDT)
Message-ID: <4CA089B5.80601@HIDDEN>
Date: Mon, 27 Sep 2010 14:10:29 +0200
From: Ryan Johnson <ryanjohn@HIDDEN>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
	rv:1.9.2.8) Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2
MIME-Version: 1.0
To: bug-gnu-emacs@HIDDEN
Subject: 23.2.2 mangles terminal escape sequences
Content-Type: multipart/alternative;
	boundary="------------010104000604040200050109"
X-detected-operating-system: by eggs.gnu.org: Solaris 9
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older,
	4)
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -5.3 (-----)

This is a multi-part message in MIME format.
--------------010104000604040200050109
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

  Hi all,

Emacs-23.2 occasionally loses parts of terminal escape sequences, 
confusing xt-mouse.el and dumping garbage text in the user's buffer.

Steps to reproduce:

   1. ssh to a machine with emacs-23 installed (I suspect slower
      networks would expose this more, but the bug bites me even over
      intranet)
   2. compile tee-input.c (see below) into a shared library (on solaris:
      `cc -g -G -xcode=pic13 -ldl -hlibtee-input.so tee-input.c -g -o
      libtee-input.so')
   3. invoke `LD_PRELOAD=libtee-input.so emacs -nw -Q 2>input.txt'
   4. M-x xterm-mouse-mode
   5. flick the mouse scroll wheel hard, so it generates many ticks in
      quick succession (note the garbage that results)
   6. M-x show-lossage (note the mangled escape sequences)
   7. C-x C-c
   8. Examine input.txt (note the intact escape sequences)

Doing the above with emacs-22.3.1 always works fine, but emacs-23.2.2 
mangles one or more escape sequences (input.txt is not corrupted). I 
suspect this and bug #6920 are symptoms of the same problem.

The number of characters missing ranges from 1 (only ESC missing) to all 
but one (only [ present); I don't think I've yet seen an entire sequence 
disappear. The harder the flick the more numerous the mangled escape 
sequences. It's not an OS issue because I can reproduce it on three very 
different machines (32-bit cygwin, 64-bit redhat, 32-bit solaris). It's 
also not a problem with the terminal because the intercepted input is 
correct. Finally, it's not a problem with xt-mouse.el because 
show-lossage is incorrect.

To give one example I generated using the above steps, emacs *scratch* 
buffer shows:
`b[[M`b[

The output of show-lossage is (note the orphaned ` b [, and later the 
orphaned [, and finally the orphaned M ` b [):
ESC [ > 7 7 ; 9 0 0 ; 0 c ESC x x t e r m - m o u s
e TAB RET ESC [ M ` b [ ` b [ ESC [ M ` b [ ESC [ M
` b [ ESC [ M ` b [ ESC [ M ` b [ ESC [ M ` b [ [ M
` b [ ESC [ M ` b [ ESC O P l

The relevant snippet of input.txt is:
;;;;;ESC[M`b[ESC[M`b[ESC[M`b[ESC[M`b[ESC[M`b[ESC[M`b[ESC[M`b[ESC[M`b[ESC[M`b[ESC[M`b[ESC[M`b[ESCOPl

Thoughts?
Ryan

===== tee-input.c ====
#include <dlfcn.h>
#include <unistd.h>
typedef ssize_t (*read_func)(int fildes, void *buf, size_t nbyte);
ssize_t read(int fildes, void *buf, size_t nbyte) {
     static read_func old_read = 0;
     if(!old_read)
         old_read = (read_func) dlsym(RTLD_NEXT, "read");
     ssize_t rval = old_read(fildes, buf, nbyte);
     if(rval > 0)
         write(2, buf, rval);
     return rval;
}
=================


--------------010104000604040200050109
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Hi all,<br>
    <br>
    Emacs-23.2 occasionally loses parts of terminal escape sequences,
    confusing xt-mouse.el and dumping garbage text in the user's buffer.
    <br>
    <br>
    Steps to reproduce:<br>
    <ol>
      <li>ssh to a machine with emacs-23 installed (I suspect slower
        networks would expose this more, but the bug bites me even over
        intranet)<br>
      </li>
      <li>compile tee-input.c (see below) into a shared library (on
        solaris: `cc -g -G -xcode=pic13 -ldl -hlibtee-input.so
        tee-input.c -g -o libtee-input.so')</li>
      <li>invoke `LD_PRELOAD=libtee-input.so emacs -nw -Q 2&gt;input.txt'</li>
      <li>M-x xterm-mouse-mode</li>
      <li>flick the mouse scroll wheel hard, so it generates many ticks
        in quick succession (note the garbage that results)</li>
      <li>M-x show-lossage (note the mangled escape sequences)<br>
      </li>
      <li>C-x C-c</li>
      <li>Examine input.txt (note the intact escape sequences)<br>
      </li>
    </ol>
    Doing the above with emacs-22.3.1 always works fine, but
    emacs-23.2.2 mangles one or more escape sequences (input.txt is not
    corrupted). I suspect this and bug #6920 are symptoms of the same
    problem. <br>
    <br>
    The number of characters missing ranges from 1 (only ESC missing) to
    all but one (only [ present); I don't think I've yet seen an entire
    sequence disappear. The harder the flick the more numerous the
    mangled escape sequences. It's not an OS issue because I can
    reproduce it on three very different machines (32-bit cygwin, 64-bit
    redhat, 32-bit solaris). It's also not a problem with the terminal
    because the intercepted input is correct. Finally, it's not a
    problem with xt-mouse.el because show-lossage is incorrect.<br>
    <br>
    To give one example I generated using the above steps, emacs
    *scratch* buffer shows: <br>
    `b[[M`b[<br>
    <br>
    The output of show-lossage is (note the orphaned ` b [, and later
    the orphaned [, and finally the orphaned M ` b [): <br>
    ESC [ &gt; 7 7 ; 9 0 0 ; 0 c ESC x x t e r m - m o u s<br>
    e TAB RET ESC [ M ` b [ ` b [ ESC [ M ` b [ ESC [ M<br>
    ` b [ ESC [ M ` b [ ESC [ M ` b [ ESC [ M ` b [ [ M<br>
    ` b [ ESC [ M ` b [ ESC O P l<br>
    <br>
    The relevant snippet of input.txt is:<br>
;;;;;ESC[M`b[ESC[M`b[ESC[M`b[ESC[M`b[ESC[M`b[ESC[M`b[ESC[M`b[ESC[M`b[ESC[M`b[ESC[M`b[ESC[M`b[ESCOPl<br>
    <br>
    Thoughts?<br>
    Ryan<br>
    <br>
    ===== tee-input.c ====<br>
    #include &lt;dlfcn.h&gt;<br>
    #include &lt;unistd.h&gt;<br>
    typedef ssize_t (*read_func)(int fildes, void *buf, size_t nbyte);<br>
    ssize_t read(int fildes, void *buf, size_t nbyte) {<br>
    &nbsp;&nbsp;&nbsp; static read_func old_read = 0;<br>
    &nbsp;&nbsp;&nbsp; if(!old_read)<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; old_read = (read_func) dlsym(RTLD_NEXT, "read");<br>
    &nbsp;&nbsp;&nbsp; ssize_t rval = old_read(fildes, buf, nbyte);<br>
    &nbsp;&nbsp;&nbsp; if(rval &gt; 0)<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write(2, buf, rval);<br>
    &nbsp;&nbsp;&nbsp; return rval;<br>
    }<br>
    =================<br>
    <br>
  </body>
</html>

--------------010104000604040200050109--




Acknowledgement sent to Ryan Johnson <ryanjohn@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#7117; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.