GNU bug report logs - #31793
26.1; (error "Lisp nesting exceeds ‘max-lisp-eval-depth’")

Previous Next

Package: emacs;

Reported by: Leo Liu <sdl.web <at> gmail.com>

Date: Tue, 12 Jun 2018 02:33:02 UTC

Severity: normal

Tags: fixed

Found in version 26.1

Fixed in version 26.2

Done: Noam Postavsky <npostavs <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: John Shahid <jvshahid <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 31793 <at> debbugs.gnu.org, Noam Postavsky <npostavs <at> gmail.com>, sdl.web <at> gmail.com
Subject: bug#31793: 26.1; (error "Lisp nesting exceeds ‘max-lisp-eval-depth’")
Date: Thu, 05 Jul 2018 16:33:29 +0000
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Noam Postavsky <npostavs <at> gmail.com>
>> Cc: Leo Liu <sdl.web <at> gmail.com>,  31793 <at> debbugs.gnu.org,  Eli Zaretskii <eliz <at> gnu.org>
>> Date: Wed, 04 Jul 2018 18:38:40 -0400
>>
>> >> The problem is in step 4. The eldoc-global-mode buffer list isn't reset
>> >> in step 2. Step 4 will try to enabe the mode for the same buffer and
>> >> start a sequence of calls at 2. I was able to fix this problem by
>> >> setting the buffer-list to nil inside ,MODE-enable-in-buffers. I
>> >> attached a patch below.
>>
>> Looks good to me.  I guess there is some risk since we are modifying a
>> macro which affects a lot of modes, but when balanced against the "risk"
>> that we actually fix similar problems in those modes I think this should
>> go to emacs-26.
>
> OK, but please add a comment there explaining why we set the
> MODE-buffers to nil.
>
>> > Added the bug number to the changelog entry and attached a new patch.
>> >
>> >>From 893e62ee7e3630c981adb3efa39ef409500d7657 Mon Sep 17 00:00:00 2001
>> > From: John Shahid <jvshahid <at> gmail.com>
>> > Date: Sat, 23 Jun 2018 11:12:44 -0400
>> > Subject: [PATCH] Avoid turning on the global-minor-mode recursively
>> >  (Bug#31793)
>
> It is better to add the bug number to the body of the log message,
> not to the header, because the latter has only limited space.
>
>> > * lisp/emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Reset
>> >   the buffer-list inside ,MODE-enable-in-buffers to avoid enabling the
>> >   mode recursively
>>
>> I would drop that comma from the commit message though, it's not really
>> part of the variable name, it's only meaningful in the context of a
>> backquote (and you forgot the period at the end of the sentence).
>
> Agreed.

Thanks for taking a look and reviewing the patch. Attached a new patch
with the suggested changes.

Cheers,

[0001-Avoid-turning-on-the-global-minor-mode-recursively.patch (text/x-diff, inline)]
From b8de8143d74777f25c9ec6f867c040332de810c4 Mon Sep 17 00:00:00 2001
From: John Shahid <jvshahid <at> gmail.com>
Date: Sat, 23 Jun 2018 11:12:44 -0400
Subject: [PATCH] Avoid turning on the global-minor-mode recursively

* lisp/emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Clear
  the buffer-list inside MODE-enable-in-buffers to avoid enabling the
  mode recursively.  (Bug#31793)
---
 lisp/emacs-lisp/easy-mmode.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index b83b53a8e5..6bf657848c 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -474,7 +474,12 @@ define-globalized-minor-mode
 
        ;; The function that calls TURN-ON in each buffer.
        (defun ,MODE-enable-in-buffers ()
-	 (dolist (buf ,MODE-buffers)
+         (let ((buffers ,MODE-buffers))
+           ;; Clear MODE-buffers to avoid scanning the same list of
+           ;; buffers in recursive calls to MODE-enable-in-buffers.
+           ;; Otherwise it could lead to infinite recursion.
+           (setq ,MODE-buffers nil)
+           (dolist (buf buffers)
 	   (when (buffer-live-p buf)
 	     (with-current-buffer buf
                (unless ,MODE-set-explicitly
@@ -484,12 +489,11 @@ define-globalized-minor-mode
 			 (,mode -1)
 			 (funcall #',turn-on))
 		     (funcall #',turn-on))))
-	       (setq ,MODE-major-mode major-mode)))))
+                 (setq ,MODE-major-mode major-mode))))))
        (put ',MODE-enable-in-buffers 'definition-name ',global-mode)
 
        (defun ,MODE-check-buffers ()
 	 (,MODE-enable-in-buffers)
-	 (setq ,MODE-buffers nil)
 	 (remove-hook 'post-command-hook ',MODE-check-buffers))
        (put ',MODE-check-buffers 'definition-name ',global-mode)
 
-- 
2.18.0


This bug report was last modified 7 years and 9 days ago.

Previous Next


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