From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ryan Johnson Newsgroups: gmane.emacs.bugs Subject: bug#7117: 23.2.2 mangles terminal escape sequences Date: Mon, 27 Sep 2010 14:10:29 +0200 Message-ID: <4CA089B5.80601@ece.cmu.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------010104000604040200050109" X-Trace: dough.gmane.org 1285596658 22191 80.91.229.12 (27 Sep 2010 14:10:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 27 Sep 2010 14:10:58 +0000 (UTC) To: 7117@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Sep 27 16:10:56 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P0EPt-0005z8-Pg for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Sep 2010 16:10:54 +0200 Original-Received: from localhost ([127.0.0.1]:50426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0EPt-0006Xh-6S for geb-bug-gnu-emacs@m.gmane.org; Mon, 27 Sep 2010 10:10:53 -0400 Original-Received: from [140.186.70.92] (port=40005 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0CYB-0001yZ-Nj for bug-gnu-emacs@gnu.org; Mon, 27 Sep 2010 08:11:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0CYA-00053l-Dm for bug-gnu-emacs@gnu.org; Mon, 27 Sep 2010 08:11:19 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38053) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0CYA-00053h-Aw for bug-gnu-emacs@gnu.org; Mon, 27 Sep 2010 08:11:18 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1P0CV0-0006Al-2u; Mon, 27 Sep 2010 08:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ryan Johnson Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Sep 2010 12:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 7117 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.128558928023718 (code B ref -1); Mon, 27 Sep 2010 12:08:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Sep 2010 12:08:00 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0CUx-0006AV-03 for submit@debbugs.gnu.org; Mon, 27 Sep 2010 08:07:59 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0CUv-0006AQ-8S for submit@debbugs.gnu.org; Mon, 27 Sep 2010 08:07:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0CXb-0004yN-K7 for submit@debbugs.gnu.org; Mon, 27 Sep 2010 08:10:44 -0400 Original-Received: from lists.gnu.org ([199.232.76.165]:56098) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0CXb-0004yG-GN for submit@debbugs.gnu.org; Mon, 27 Sep 2010 08:10:43 -0400 Original-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@gnu.org; Mon, 27 Sep 2010 08:10:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0CXV-0004xa-5p for bug-gnu-emacs@gnu.org; Mon, 27 Sep 2010 08:10:41 -0400 Original-Received: from bache.ece.cmu.edu ([128.2.129.23]:58259) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0CXV-0004xD-2E for bug-gnu-emacs@gnu.org; Mon, 27 Sep 2010 08:10:37 -0400 Original-Received: from [128.178.77.144] (diaspc12.epfl.ch [128.178.77.144]) by bache.ece.cmu.edu (Postfix) with ESMTP id 3B37BA2 for ; Mon, 27 Sep 2010 08:10:34 -0400 (EDT) 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 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 27 Sep 2010 08:08:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Mailman-Approved-At: Mon, 27 Sep 2010 10:10:47 -0400 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:40488 Archived-At: 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 #include 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 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--