Tracking down max-specpdl-size errors in emacs

Jason Baker picture Jason Baker · Aug 24, 2009 · Viewed 9.5k times · Source

I've been randomly getting the following error in emacs:

Variable binding depth exceeds max-specpdl-size

...and I've been getting it at very random moments. After researching this, it seems as though some elisp somewhere is recursing too deeply. Are there any strategies for tracking this down? I'm totally at a loss as far as what is actually causing this.

I've gotten some errors indicating something along the lines of infinite recursion with ropemacs (but these are usually Python errors). Could something be misconfigured with ropemacs?

Update: Interestingly enough, I've found that I always get this error if I do a "C-h a" for "speedbar" but not for "rope-".

Answer

Trey Jackson picture Trey Jackson · Aug 24, 2009

To track the problem down, you can try this:

(setq max-specpdl-size 5)  ; default is 1000, reduce the backtrace level
(setq debug-on-error t)    ; now you should get a backtrace
C-h a ; in speedbar

You should get a backtrace upon the error, and at that point, you can track down the offending routine.

I'd also try loading emacs w/out your configuration file (emacs -q), to see if there's something in your .emacs that is affecting things. (I don't get the infinite loop using C-h a). And if it is your .emacs, then the best way I've found to track that down is either binary search (put an error (error "frog") or somesuch in the middle of your .emacs, load, test, if no problems, put the error at 3/4, otherwise at 1/4, repeat...), or manually evaluate your .emacs line by line (region by region), testing after each portion. Those settings should help.