unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ami Fischman" <ami@fischman.org>
To: emacs-devel@gnu.org
Subject: poor handling of multiple C-g with multi-tty (apparent hangs)
Date: Sun, 10 Aug 2008 23:14:21 -0700	[thread overview]
Message-ID: <b5a678470808102314p40edbfa1m9545c1d0d7ffd12c@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2861 bytes --]

Emacs has code to deal with C-g being entered while a quit is already in
progress, meant to suspend emacs and drop the user to the superior shell or
debugger (see section 59.7 Emergency Escape of the emacs info).  This is
done if emacs believes it's a good idea, which criteria includes "running in
tty mode".  Unfortunately this was never updated to work correctly with the
multi-tty patch.  As a result the following can happen:
1) Start up an "emacs -Q -nw" (tty) instance and M-x server-start RET.
2) From another shell open a tty /or/ X frame to the same emacs.
3) In the second frame eval this and immediately hit C-g while the sleep-for
is running:
(let ((inhibit-quit t)
      (quit-flag t))
  (sleep-for 10))
4) The second frame becomes unresponsive because the first (main) frame has
suspended itself and dropped back to the invoking shell.

Note that that elisp snippet is a bit extreme - in fact this behavior can be
triggered in much more innocuous ways, such as interrupting a *compilation*
at an inopportune moment.  But I don't have a simple repro recipe like the
above for the more mundane ways this can trigger.

The relevant hint is in keyboard.c:handle_interrupt() which contains:
  /* XXX This code needs to be revised for multi-tty support. */
  if (!NILP (Vquit_flag)

I work around this in my personal builds by adding an "&& 0" to the end of
the if line above, which disables the feature described by 59.7.  An
alternative workaround is to not use tty frames, or start up in a tty frame
(say inside a GNU screen session), then start at least one X frame, and kill
the original tty frame, which still allows one to have a persistent emacs
server running that can be robust to the death of an X server (as long as it
is displaying a frame on at least one other X server).

This bug is very easy to tickle accidentally; every user I've converted to
multi-tty usage patterns that uses any tty frames (either inside a screen
session for persistence or over ssh connections for speed) has run afoul of
this at some point.  As things stand I believe the feature does more harm
than good.  Since 23.1 will be the first release of emacs to contain the
multi-tty functionality (advertised in NEWS as "Improved X Window System
support") I believe it should be fixed before release.  This will require
either declaring 59.7 obsolete (intentionally removing the capability) or
the attention of someone familiar with the workings of the tty code to
resolve the XXX in the code.

FWIW I remember this happening with multi-tty years ago and repros in HEAD
builds from 20080810, 20080702, and 20070829.  Also, I believe that
resolving this correctly should resolve Dan Nicolaescu's issue reported in
emacs-devel email titled '"Auto-save? (y or n)" question when doing C-z'
with Message-ID: <200807291757.m6THv4NF010142@sallyv1.ics.uci.edu>.

Cheers,
-a

[-- Attachment #2: Type: text/html, Size: 3223 bytes --]

             reply	other threads:[~2008-08-11  6:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-11  6:14 Ami Fischman [this message]
2008-08-11 17:40 ` poor handling of multiple C-g with multi-tty (apparent hangs) Chong Yidong
2008-08-11 18:56   ` Dan Nicolaescu
2008-08-11 22:00     ` Chong Yidong
2008-08-12  4:53     ` Richard M. Stallman
2008-08-11 21:19   ` Ami Fischman
     [not found] ` <48a85bf8.02a6420a.410f.ffffc5a1MFETCHER_ADDED@google.com>
2008-09-15 23:00   ` Ami Fischman
2008-09-16  3:16     ` Eli Zaretskii
2008-09-16  3:33       ` Ami Fischman
2008-09-16 14:00     ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2008-12-20 13:13 Markus Triska

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b5a678470808102314p40edbfa1m9545c1d0d7ffd12c@mail.gmail.com \
    --to=ami@fischman.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).