GNU bug report logs - #17413
24.3; trapped in an (imaginary) recursive edit

Previous Next

Package: emacs;

Reported by: Samuel Bronson <naesten <at> gmail.com>

Date: Tue, 6 May 2014 02:21:02 UTC

Severity: normal

Tags: patch

Found in version 24.3

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 17413 in the body.
You can then email your comments to 17413 AT debbugs.gnu.org in the normal way.

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#17413; Package emacs. (Tue, 06 May 2014 02:21:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Samuel Bronson <naesten <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 06 May 2014 02:21:03 GMT) Full text and rfc822 format available.

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

From: Samuel Bronson <naesten <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3; trapped in an (imaginary) recursive edit
Date: Mon, 05 May 2014 22:20:11 -0400
[Message part 1 (text/plain, inline)]
Tags: patch

As the comment in temporarily_switch_to_single_kboard () says, it is
possible for lisp code to call `recursive-edit' (or one of its callers)
while the keyboard for the selected frame is locked.  And it is indeed
better to throw an error when this happens than to leave the user with a
frozen screen.  (I don't properly understand the circumstances I saw it
in, but they involved emacs --daemon and a terminal which did not
actually work.)

One small problem: this happens *after* the line:
  command_loop_level++;
but before the line:
  record_unwind_protect (recursive_edit_unwind, buffer);
which registers the code that does the corresponding:
  command_loop_level--;

So the user will be left with every indication that they're in a
recursive edit, except that when they try to use C-M-c it will give them
a cryptic error like "No catch for tag: exit, nil" in the status area
instead of zapping those pesky square brackets.

Here's a patch against master to fix that:
[Message part 2 (text/x-patch, inline)]
diff --git a/src/keyboard.c b/src/keyboard.c
index d52483e..a5a9ad9 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -825,22 +825,25 @@ This function is called by the editor initialization to begin editing.  */)
   if (input_blocked_p ())
     return Qnil;
 
-  command_loop_level++;
-  update_mode_lines = 17;
-
-  if (command_loop_level
+  if (command_loop_level >= 0
       && current_buffer != XBUFFER (XWINDOW (selected_window)->contents))
     buffer = Fcurrent_buffer ();
   else
     buffer = Qnil;
 
+  /* Don't do anything interesting between the increment and the
+     record_unwind_protect!  Otherwise, we could get distracted and
+     never decrement the counter again.  */
+  command_loop_level++;
+  update_mode_lines = 17;
+  record_unwind_protect (recursive_edit_unwind, buffer);
+
   /* If we leave recursive_edit_1 below with a `throw' for instance,
      like it is done in the splash screen display, we have to
      make sure that we restore single_kboard as command_loop_1
      would have done if it were left normally.  */
   if (command_loop_level > 0)
     temporarily_switch_to_single_kboard (SELECTED_FRAME ());
-  record_unwind_protect (recursive_edit_unwind, buffer);
 
   recursive_edit_1 ();
   return unbind_to (count, Qnil);
[Message part 3 (text/plain, inline)]
In GNU Emacs 24.3.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2013-12-22 on binet, modified by Debian
Windowing system distributor `Colin Harrison', version 11.0.60900031
System Description:	Debian GNU/Linux testing (jessie)

Configured using:
 `configure '--build' 'i486-linux-gnu' '--build' 'i486-linux-gnu'
 '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
 '--localstatedir=/var/lib' '--infodir=/usr/share/info'
 '--mandir=/usr/share/man' '--with-pop=yes'
 '--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.3/site-lisp:/usr/share/emacs/site-lisp'
 '--with-crt-dir=/usr/lib/i386-linux-gnu' '--with-x=yes'
 '--with-x-toolkit=lucid' '--with-toolkit-scroll-bars' '--without-gconf'
 '--without-gsettings' 'build_alias=i486-linux-gnu' 'CFLAGS=-g -O2
 -fstack-protector --param=ssp-buffer-size=4 -Wformat
 -Werror=format-security -Wall' 'LDFLAGS=-Wl,-z,relro'
 'CPPFLAGS=-D_FORTIFY_SOURCE=2''

Important settings:
  value of $LC_COLLATE: C
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Tue, 06 May 2014 16:18:01 GMT) Full text and rfc822 format available.

Notification sent to Samuel Bronson <naesten <at> gmail.com>:
bug acknowledged by developer. (Tue, 06 May 2014 16:18:02 GMT) Full text and rfc822 format available.

Message #10 received at 17413-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Samuel Bronson <naesten <at> gmail.com>
Cc: 17413-done <at> debbugs.gnu.org
Subject: Re: bug#17413: 24.3; trapped in an (imaginary) recursive edit
Date: Tue, 06 May 2014 12:17:24 -0400
> One small problem: this happens *after* the line:
>   command_loop_level++;
> but before the line:
>   record_unwind_protect (recursive_edit_unwind, buffer);
> which registers the code that does the corresponding:
>   command_loop_level--;

Oops, thanks for spotting this.  Patch installed into the
emacs-24 branch.


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 04 Jun 2014 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 110 days ago.

Previous Next


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