Issue #368 resolved

variable binding depth exceeds max-specpdl-size on cygwin

Scott Determan
created an issue

If I try to use evil on cygwin's emacs, I get the following error when I try to load a file: variable binding depth exceeds max-specpdl-size

And the file does not load.

If I disable evil on startup, then I can load files and everything seems OK. If I load evil after startup with M-x evil-mode, then I get the following message in my mode-line:

ad-handle-definition: 'display buffer' got redefined (and then I'll get the same max-specpdl-size errors when loading a file).

In evil-core.el, if I comment out the following two 'defadvice' functions then things seem to work OK (although I'm sure I'll notice what this breaks later): display-buffer switch-to-buffer

This only happens in cygwin's emacs. I use evil all the time in "regular" windows emacs and linux emacs. Cygwin's emacs is 24.3.1

I am using evil from git master branch. pulled on 1/4/2014.

Comments (18)

  1. Frank Fischer repo owner
    • changed status to open

    I'm sorry, but I do not have access to a windows machine, so I can't reproduce the problem and investigate.

    Maybe someone else can have a look? (you might also ask on the mailing list)

  2. Maxim Ivanov

    I see exactly same behavior on my OpenSUSE using emacs 24.3:

    For information about GNU Emacs and the GNU system, type C-h C-a.
    Quit
    evil <<<<<<<< require evil
    ad-handle-definition: `toggle-input-method' got redefined
    ad-handle-definition: `switch-to-buffer' got redefined
    ad-handle-definition: `display-buffer' got redefined
    t <<<<<<<<< (evil-mode t)
    ad-Orig-switch-to-buffer: Variable binding depth exceeds max-specpdl-size <<< attempt to switch to any  other buffer
    
  3. Maxim Ivanov

    It seems to depend on whether "(package-initialize)" is above or before (require 'evil) call. Here is minimal config

    (add-to-list 'load-path "~/repos/evil")
    ;; following triggers error
    ;(package-initialize)
    (require 'evil)
    ;; following works ok (given that one above is commented)
    ;(package-initialize)
    (evil-mode 1)
    

    I save above to init_min.el and start emacs with following

    emacs -q -l init_min.el
    
  4. Maxim Ivanov

    I narrowed it down to conflict with gh package (http://melpa.milkbox.net/#/gh) and it's dependencies. So final steps to reproduce:

    1. configure MELPA packages repo in emacs
    2. clean ~/.emacs.d/elpa
    3. download "gh-20140121.2038" using package manager, so that content of ~/.emacs.d/elpa is following
    gh-20140121.2038  logito-20120225.1255  pcache-20131201.1159
    
    1. cd to evil checkout
    2. run it as following
    emacs  -q  -L . --eval "(package-initialize)"  --eval "(require 'evil)" --eval "(evil-mode 1)"
    
    1. try to switch to "Messages" buffer
  5. Frank Fischer repo owner

    I still have trouble to reproduce the problem. However, I'm curious. The steps you describe initialize the package system, okay, but they should not load gh.el -- only the autoload files should be loaded. As long as no gh-specific function is called, no "real" file of gh should be loaded at all. However, gh-autoloads.el requires 'eieio.

    So, this raises two questions:

    1. does loading of package.el cause the problem? I guess not, because it seems only to happen if you have gh installed, doesn't it?

    2. Maybe eieio causes the problem. What happens if you load eieio directly, i.e. something like

    emacs -q -L . --eval "(require 'eieio)" --eval "(require 'evil)" \
      --eval "(evil-mode 1)"
    

    If the latter does not cause a problem ... is it possible to reproduce the problem without package-initialize, e.g. by using gh and its dependencies directly?

    Thanks, Frank

  6. Frank Fischer repo owner

    Okay. eieio does a lot of funny things, so I'm not too surprised. However it works for me, so I still can't reproduce the problem. Maybe I find another machine where the problem occurs ...

  7. Frank Fischer repo owner

    Could you please check if the following patch works:

    diff -r 637573c60835 -r 4faef510d66e evil-core.el
    --- a/evil-core.el      Fri Mar 14 22:34:24 2014 +0100
    +++ b/evil-core.el      Sat Mar 22 23:42:53 2014 +0100
    @@ -342,7 +342,7 @@
     ;; run. This is appropriate since many buffers are used for throwaway
     ;; purposes. Passing the buffer to `display-buffer' indicates
     ;; otherwise, though, so advise this function to initialize Evil.
    -(defadvice display-buffer (before evil activate)
    +(defadvice display-buffer (before evil)
       "Initialize Evil in the displayed buffer."
       (when evil-mode
         (when (get-buffer (ad-get-arg 0))
    @@ -350,7 +350,7 @@
             (unless evil-local-mode
               (evil-local-mode 1))))))
    
    -(defadvice switch-to-buffer (before evil activate)
    +(defadvice switch-to-buffer (before evil)
       "Initialize Evil in the displayed buffer."
       (when evil-mode
         (let* ((arg0 (ad-get-arg 0))
    @@ -426,7 +426,7 @@
           (setq evil-input-method nil))))
     (put 'evil-deactivate-input-method 'permanent-local-hook t)
    
    -(defadvice toggle-input-method (around evil activate)
    +(defadvice toggle-input-method (around evil)
       "Refresh `evil-input-method'."
       (cond
        ((not evil-local-mode)
    
  8. Frank Fischer repo owner

    disable premature activation of some advises (fix #368)

    Premature of advises of display-buffer and switch-to-buffer may cause trouble in some Emacs versions. This change does not activate the advises immediately but on definition. However, all advises are activated when evil-mode is enabled anyway, so this should not cause any troubles.

    → <<cset 4faef510d66e>>

  9. Frank Fischer repo owner

    Great!

    And thanks for your report. An analysis like yours is invaluable to track down a bug. Without, it would be really hard to find what goes wrong.

  10. Frank Fischer repo owner

    disable premature activation of some advises (fix #368)

    Premature of advises of display-buffer and switch-to-buffer may cause trouble in some Emacs versions. This change does not activate the advises immediately but on definition. However, all advises are activated when evil-mode is enabled anyway, so this should not cause any troubles.

    → <<cset 4faef510d66e>>

  11. Log in to comment