Subject: bug#24713: closed (Re: bug#24713: 26.0.50; edebug-max-depth should be customizable)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 04 Feb 2017 11:06:02 +0000

Your bug report

#24713: 26.0.50; edebug-max-depth should be customizable

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
24713: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=24713
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#24713: 26.0.50; edebug-max-depth should be customizable
From: Eli Zaretskii <[email-masked]>
To: Gemini Lasswell <[email-masked]>
Cc: [email-masked]
Date: Sat, 04 Feb 2017 13:05:13 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Gemini Lasswell <[email-masked]>
> Date: Sun, 16 Oct 2016 14:58:44 -0700
> 
> Edebug's recursion limit is currently 150, but this is not enough for
> the following files in the Emacs source tree:
> 
> lisp/calc/calc-ext.el
> lisp/help-macro.el
> lisp/international/fontset.el
> 
> The latter two can be successfully instrumented with edebug-max-depth
> set to 200, but the minimum value necessary for calc-ext.el is somewhere
> between 500 and 1000. All three of these files contain large quoted
> lists.
> 
> I'm attaching a patch to accomplish this.

Thanks, pushed.

A few minor nits for the future:

 . when you add/modify a defcustom, always specify a :version tag
 . please always mention the bug number in the commit log message,
   otherwise it must be added by hand, which is error-prone
 . user-visible changes should be accompanied by suitable changes to
   NEWS and the manuals (I did it this time)
 . please use the US English convention of leaving 2 spaces between
   sentences -- this is what we use in Emacs documentation
 . please configure your Git repo (on Github?) so that your user name
   is identical to what you use to send email, to avoid confusion

Subject: 26.0.50; edebug-max-depth should be customizable
From: Gemini Lasswell <[email-masked]>
To: [email-masked]
Date: Sun, 16 Oct 2016 14:58:44 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Edebug's recursion limit is currently 150, but this is not enough for
the following files in the Emacs source tree:

lisp/calc/calc-ext.el
lisp/help-macro.el
lisp/international/fontset.el

The latter two can be successfully instrumented with edebug-max-depth
set to 200, but the minimum value necessary for calc-ext.el is somewhere
between 500 and 1000. All three of these files contain large quoted
lists.

I'm attaching a patch to accomplish this. I chose to mention
max-lisp-eval-depth and max-specpdl-size in the defcustom docstring, but
I also noticed that Edebug temporarily bumps max-lisp-eval-depth up by
800 while it's working. I could modify the patch to replace the 800 by
something along the lines of (+ 200 (* max-edebug-depth 4)), if someone
with more Emacs experience than me says it is a good idea. Edebug also
increases max-specpdl-size (by 2000) so that probably would also need to
be changed in the code.

>From 860deea4d3ff07c105435ac36c8477fcb6e1d008 Mon Sep 17 00:00:00 2001
From: gazally <[email-masked]>
Date: Sun, 16 Oct 2016 13:34:56 -0700
Subject: [PATCH] Change edebug-max-depth from defconst to defcustom

Make edebug-max-depth customizable to give Edebug the ability to
instrument code containing very large quoted lists.
* lisp/emacs-lisp/edebug.el (edebug-max-depth): Add defcustom.
---
 lisp/emacs-lisp/edebug.el | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index 6918539..facbda8 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -112,6 +112,18 @@ edebug-eval-macro-args
   :type 'boolean
   :group 'edebug)
 
+(defcustom edebug-max-depth 150
+  "Maximum recursion depth when instrumenting code.
+This limit stops recursion if an Edebug specification contains an
+infinite loop. When Edebug is instrumenting code containing very
+large quoted lists, it may reach this limit and give the error
+message \"Too deep - perhaps infinite loop in spec?\" You can
+safely make this limit considerably larger than its default
+value, but you may also need to increase `max-lisp-eval-depth'
+and `max-specpdl-size'."
+  :type 'integer
+  :group 'edebug)
+
 (defcustom edebug-save-windows t
   "If non-nil, Edebug saves and restores the window configuration.
 That takes some time, so if your program does not care what happens to
@@ -1452,7 +1464,6 @@ edebug-list-form
 (defvar edebug-after-dotted-spec nil)
 
 (defvar edebug-matching-depth 0)  ;; initial value
-(defconst edebug-max-depth 150)  ;; maximum number of matching recursions.

 ;;; Failure to match
-- 
2.10.1