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


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

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

> Leo Liu <sdl.web <at> gmail.com> writes:
>
>> On 2018-06-12 08:21 +0300, Eli Zaretskii wrote:
>>> Ugh, macOS...  This means no xbacktrace and no other GDB
>>> wizardry...
>>
>> Indeed.
>>
>>> Well, I think the most important thing is to produce a Lisp
>>> backtrace from the error.
>>
>> Turns out 26.1 cannot load a version of python.el (by dave love) that I
>> have in my site-lisp.
>>
>> 1. emacs -Q -l python.el
>> 2. M-x python-mode
>>
>> ,----[ error ]
>> | Variable binding depth exceeds max-specpdl-size
>> | Error in post-command-hook (global-eldoc-mode-check-buffers): (error "Variable binding depth exceeds max-specpdl-size")
>> `----
>>
>> Gnus was just loading python-mode to fontify some code in an article.
>
> double posting since I sent the email only to Leo.
>
> VVVV original email VVVV
>
> That seems to be a result of converting `global-eldoc-mode' to use
> `define-globalized-minor-mode' in 2349f. The recursive call seems to be
> a result of the following sequence of calls:
>
> 1. python-mode is enabled which adds an eldoc-mode-hook
> 2. eldoc-mode is turned on in the buffer triggering python's
> eldoc-mode-hook
> 3. python-mode hook will start an inferior process which in turn trigger
> ,MODE-enable-in-buffers
> 4. ,MODE-enable-in-buffers will go over the list again trying to enable
> eldoc-mode
>
> 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.

Added the bug number to the changelog entry and attached a new patch.

[0001-Avoid-turning-on-the-global-minor-mode-recursively-B.patch (text/x-diff, inline)]
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)

* 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
---
 lisp/emacs-lisp/easy-mmode.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index b83b53a8e5..648b88ca77 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -474,7 +474,9 @@ 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))
+           (setq ,MODE-buffers nil)
+           (dolist (buf buffers)
 	   (when (buffer-live-p buf)
 	     (with-current-buffer buf
                (unless ,MODE-set-explicitly
@@ -484,12 +486,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.