GNU bug report logs - #10959
23.3; emacs -nw doesn't always restore the terminal screen

Previous Next

Package: emacs;

Reported by: Vincent Lefevre <vincent <at> vinc17.net>

Date: Tue, 6 Mar 2012 15:03:01 UTC

Severity: normal

Merged with 14491, 15013

Found in version 23.3

To reply to this bug, email your comments to 10959 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#10959; Package emacs. (Tue, 06 Mar 2012 15:03:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Vincent Lefevre <vincent <at> vinc17.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 06 Mar 2012 15:03:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Vincent Lefevre <vincent <at> vinc17.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.3; emacs -nw doesn't always restore the terminal screen
Date: Tue, 6 Mar 2012 16:01:04 +0100
This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your report will be posted to the bug-gnu-emacs <at> gnu.org mailing list
and the gnu.emacs.bug news group, and at http://debbugs.gnu.org.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug.  If you can, give
a recipe starting from `emacs -Q':

When run in a terminal (at least in xterm, aterm and gnome-terminal),
emacs doesn't always restore the terminal screen (it remains in the
alternate screen). This can be reproduced, but not always, with:

  for i in `seq 1 200`
  do
    emacs -Q -nw --eval '(save-buffers-kill-terminal)'
  done

One sees that the screen isn't restored as expected. You can increase
the number of iterations to have a better chance to reproduce the bug.

I couldn't reproduce this bug in rxvt-unicode.

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
/usr/local/emacs-23.3b/share/emacs/23.3/etc/DEBUG.


In GNU Emacs 23.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.8)
 of 2011-12-15 on xvii
configured using `configure  '--prefix=/usr/local/emacs-23.3b' '--enable-asserts' '--with-crt-dir=/usr/lib/x86_64-linux-gnu''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: POSIX
  value of $LC_CTYPE: en_US.UTF-8
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: en_DK
  value of $LANG: POSIX
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  display-time-mode: t
  show-paren-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
ESC [ > 0 ; 2 7 6 ; 0 c ESC ] 1 1 ; r g b : 0 0 0 0 
/ 0 0 0 0 / 0 0 0 0 ESC \ C-h C-p C-s a l t e r n a 
C-s C-r C-r C-s C-s C-s C-s ESC O H C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s ESC O H C-s t e 
r m i n a l C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s ESC O H C-s s s 
h C-s C-s C-s C-s C-s C-s C-s C-s ESC O B ESC [ 6 ~ 
ESC [ 6 ~ ESC [ 6 ~ ESC [ 6 ~ q ESC x r e p o TAB r 
t TAB RET

Recent messages:
Note: file is write protected
View mode: type C-h for help, h for commands, q to quit.
Mark saved where search started
Mark set
Mark saved where search started
Mark set
Mark saved where search started
Mark set
Mark saved where search started
Making completion list...

Load-path shadows:
None found.

Features:
(shadow sort mail-extr message sendmail ecomplete rfc822 mml mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1
hex-util hashcash mail-utils warnings emacsbug help-mode easymenu
multi-isearch goto-addr thingatpt noutline outline easy-mmode view time
cus-start cus-load paren cc-styles cc-align cc-engine cc-vars cc-defs
regexp-opt tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win
x-dnd font-setting tool-bar dnd fontset image fringe lisp-mode register
page menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind system-font-setting
font-render-setting gtk x-toolkit x multi-tty emacs)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10959; Package emacs. (Thu, 22 Mar 2012 11:51:02 GMT) Full text and rfc822 format available.

Message #8 received at 10959 <at> debbugs.gnu.org (full text, mbox):

From: Vincent Lefevre <vincent <at> vinc17.net>
To: 10959 <at> debbugs.gnu.org
Subject: Re: 23.3; emacs -nw doesn't always restore the terminal screen
Date: Thu, 22 Mar 2012 12:19:20 +0100
On 2012-03-06 16:01:04 +0100, Vincent Lefevre wrote:
> When run in a terminal (at least in xterm, aterm and gnome-terminal),
> emacs doesn't always restore the terminal screen (it remains in the
> alternate screen). This can be reproduced, but not always, with:
> 
>   for i in `seq 1 200`
>   do
>     emacs -Q -nw --eval '(save-buffers-kill-terminal)'
>   done
> 
> One sees that the screen isn't restored as expected. You can increase
> the number of iterations to have a better chance to reproduce the bug.
[...]

This problem still occurs with GNU Emacs 23.4.1 from the Debian
package emacs23 23.4+1-2 (tested in xterm).

-- 
Vincent Lefèvre <vincent <at> vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10959; Package emacs. (Thu, 22 Mar 2012 11:57:01 GMT) Full text and rfc822 format available.

Message #11 received at 10959 <at> debbugs.gnu.org (full text, mbox):

From: Vincent Lefevre <vincent <at> vinc17.net>
To: 10959 <at> debbugs.gnu.org
Subject: Re: 23.3; emacs -nw doesn't always restore the terminal screen
Date: Thu, 22 Mar 2012 12:25:16 +0100
On 2012-03-06 16:01:04 +0100, Vincent Lefevre wrote:
> When run in a terminal (at least in xterm, aterm and gnome-terminal),
> emacs doesn't always restore the terminal screen (it remains in the
> alternate screen). This can be reproduced, but not always, with:
> 
>   for i in `seq 1 200`
>   do
>     emacs -Q -nw --eval '(save-buffers-kill-terminal)'
>   done
> 
> One sees that the screen isn't restored as expected. You can increase
> the number of iterations to have a better chance to reproduce the bug.

This bug might be a consequence of

  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=646798

but I don't know how to test...

-- 
Vincent Lefèvre <vincent <at> vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10959; Package emacs. (Thu, 22 Mar 2012 16:10:01 GMT) Full text and rfc822 format available.

Message #14 received at 10959 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Vincent Lefevre <vincent <at> vinc17.net>
Cc: 10959 <at> debbugs.gnu.org
Subject: Re: bug#10959: 23.3;
	emacs -nw doesn't always restore the terminal screen
Date: Thu, 22 Mar 2012 11:38:22 -0400
> When run in a terminal (at least in xterm, aterm and gnome-terminal),
> emacs doesn't always restore the terminal screen (it remains in the
> alternate screen). This can be reproduced, but not always, with:

>   for i in `seq 1 200`
>   do
>     emacs -Q -nw --eval '(save-buffers-kill-terminal)'
>   done

I can reproduce it here, indeed (also with the current Emacs-24
pretest).  Problem is: I don't know anything about such terminal
initialization, so we need someone who does to help us out,


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10959; Package emacs. (Fri, 15 Jun 2012 14:25:01 GMT) Full text and rfc822 format available.

Message #17 received at 10959 <at> debbugs.gnu.org (full text, mbox):

From: Vincent Lefevre <vincent <at> vinc17.net>
To: 10959 <at> debbugs.gnu.org
Subject: Re: 23.3; emacs -nw doesn't always restore the terminal screen
Date: Fri, 15 Jun 2012 16:21:13 +0200
On 2012-03-22 12:19:20 +0100, Vincent Lefevre wrote:
> This problem still occurs with GNU Emacs 23.4.1 from the Debian
> package emacs23 23.4+1-2 (tested in xterm).

and it still occurs with the official GNU Emacs 24.1.1.

-- 
Vincent Lefèvre <vincent <at> vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10959; Package emacs. (Sat, 16 Jun 2012 06:30:02 GMT) Full text and rfc822 format available.

Message #20 received at 10959 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Vincent Lefevre <vincent <at> vinc17.net>
Cc: 10959 <at> debbugs.gnu.org
Subject: Re: bug#10959: 23.3;
	emacs -nw doesn't always restore the terminal screen
Date: Sat, 16 Jun 2012 02:26:41 -0400
>> This problem still occurs with GNU Emacs 23.4.1 from the Debian
>> package emacs23 23.4+1-2 (tested in xterm).
> and it still occurs with the official GNU Emacs 24.1.1.

Thanks for checking and confirming.  I hope someone who actually know
about such terminal setup/restore will have a chance to look at it.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10959; Package emacs. (Sat, 16 Jun 2012 07:45:01 GMT) Full text and rfc822 format available.

Message #23 received at 10959 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 10959 <at> debbugs.gnu.org, vincent <at> vinc17.net
Subject: Re: bug#10959: 23.3;
	emacs -nw doesn't always restore the terminal screen
Date: Sat, 16 Jun 2012 10:41:26 +0300
> From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
> Date: Sat, 16 Jun 2012 02:26:41 -0400
> Cc: 10959 <at> debbugs.gnu.org
> 
> >> This problem still occurs with GNU Emacs 23.4.1 from the Debian
> >> package emacs23 23.4+1-2 (tested in xterm).
> > and it still occurs with the official GNU Emacs 24.1.1.
> 
> Thanks for checking and confirming.  I hope someone who actually know
> about such terminal setup/restore will have a chance to look at it.

I know very little about this, but here's what I know: this feature
relies upon the "ti" and "te" terminal capabilities.  We use these
capabilities in tty_set_terminal_modes and tty_reset_terminal_modes,
respectively.  In both cases, we output the terminal command only if
the tty->output FILE stream is non-NULL.  So perhaps some timing
issues cause tty->output to become NULL before we get to
tty_reset_terminal_modes, or maybe it is still NULL when we get to
tty_set_terminal_modes?  In any case, adding some logs to those places
could show if that is the problem.

Alternatively, could it be a problem with the terminal emulators, not
in Emacs?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10959; Package emacs. (Sat, 16 Jun 2012 10:04:01 GMT) Full text and rfc822 format available.

Message #26 received at 10959 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 10959 <at> debbugs.gnu.org, vincent <at> vinc17.net,
	Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Subject: Re: bug#10959: 23.3;
	emacs -nw doesn't always restore the terminal screen
Date: Sat, 16 Jun 2012 18:00:31 +0800
I committed a patch to xterm.el that seems to stop the bug from
happening with the posted recipe.  It adds a `discard-input' call before
doing the xterm Report Background query, as is already done for the
Device Attributes query earlier in `terminal-init-xterm'.  I am still
not 100% sure of the chain of effect leading to the bug, though.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10959; Package emacs. (Sat, 16 Jun 2012 16:17:02 GMT) Full text and rfc822 format available.

Message #29 received at 10959 <at> debbugs.gnu.org (full text, mbox):

From: Vincent Lefevre <vincent <at> vinc17.net>
To: Eli Zaretskii <eliz <at> gnu.org>, Chong Yidong <cyd <at> gnu.org>
Cc: 10959 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Subject: Re: bug#10959: 23.3; emacs -nw doesn't always restore the terminal
	screen
Date: Sat, 16 Jun 2012 18:13:26 +0200
On 2012-06-16 10:41:26 +0300, Eli Zaretskii wrote:
> I know very little about this, but here's what I know: this feature
> relies upon the "ti" and "te" terminal capabilities.  We use these
> capabilities in tty_set_terminal_modes and tty_reset_terminal_modes,
> respectively.  In both cases, we output the terminal command only if
> the tty->output FILE stream is non-NULL.  So perhaps some timing
> issues cause tty->output to become NULL before we get to
> tty_reset_terminal_modes, or maybe it is still NULL when we get to
> tty_set_terminal_modes?

Since the bug is not always reproducible, it is likely to be a timing
problem.

> In any case, adding some logs to those places could show if that is
> the problem.

Yes, this would be a good idea.

> Alternatively, could it be a problem with the terminal emulators, not
> in Emacs?

As this problem occurs with 3 different terminal emulators (including
at least 2 very different ones: xterm and gnome-terminal), I doubt
about this.

On 2012-06-16 18:00:31 +0800, Chong Yidong wrote:
> I committed a patch to xterm.el that seems to stop the bug from
> happening with the posted recipe.  It adds a `discard-input' call before
> doing the xterm Report Background query, as is already done for the
> Device Attributes query earlier in `terminal-init-xterm'.  I am still
> not 100% sure of the chain of effect leading to the bug, though.

I wonder whether this makes the timing problem much less likely
or this is a real fix (there isn't any input from the user). Is
xterm.el also used for gnome-terminal?

Is this related to the following bug?

  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11129

-- 
Vincent Lefèvre <vincent <at> vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Merged 10959 14491. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 29 May 2013 02:55:02 GMT) Full text and rfc822 format available.

Merged 10959 14491 15013. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 02 Aug 2013 21:28:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10959; Package emacs. (Fri, 09 Oct 2015 13:00:06 GMT) Full text and rfc822 format available.

Message #36 received at 10959 <at> debbugs.gnu.org (full text, mbox):

From: Vincent Lefevre <vincent <at> vinc17.net>
To: 10959 <at> debbugs.gnu.org
Subject: Re: 23.3; emacs -nw doesn't always restore the terminal screen
Date: Fri, 9 Oct 2015 14:59:24 +0200
This bug still occurs with GNU Emacs 24.5.1 (emacs24 24.5+1-2 Debian
package). Any news?

-- 
Vincent Lefèvre <vincent <at> vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




This bug report was last modified 8 years and 209 days ago.

Previous Next


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