joaotavora / eglot

A client for Language Server Protocol servers
GNU General Public License v3.0
2.25k stars 200 forks source link

`Error: Variable binding depth exceeds max-specpdl-size` in case of big Go projects #1037

Closed mekeor closed 2 years ago

mekeor commented 2 years ago

LSP transcript

https://gist.github.com/mekeor/a30c18416cc16111999f3fc83b18dca2

Backtrace

Not possible. debug-on-error does not work. There is only the error message in the *Compile-Log* buffer: Error: Variable binding depth exceeds max-specpdl-size.

Minimum Reproducible Example

  1. Install Emacs and Go/gopls.
  2. Save this code in ~/mre.el:
    
    (cd "~")

;; download dependencies to file-system (shell-command "git clone --depth=1 https://github.com/joaotavora/eglot") (shell-command "git clone --depth=1 https://github.com/dominikh/go-mode.el go-mode")

;; download examplary code-repository to file-system (shell-command "git clone --depth=1 https://github.com/kubernetes/kubernetes")

;; add packages to load-path (add-to-list 'load-path "~/eglot") (add-to-list 'load-path "~/go-mode")

;; load dependencies into emacs (require 'project) ;; built-in (require 'eglot) (require 'go-mode)

;; make go-mode start eglot automatically (add-hook 'go-mode-hook #'eglot-ensure)

;; open any go-source-file from any big-go-project: (find-file "~/kubernetes/pkg/api/service/util.go")


3. In shell, run `emacs -Q -l ~/mre.el`.

I expect this to work. Instead, this error pops up from the `*Compile-Log*` buffer: `Error: Variable binding depth exceeds max-specpdl-size`. Sometimes it will pop up so often, that I barely can code.
joaotavora commented 2 years ago

Thanks for the recipe, it seems to be complete. Can you confirm on your end that removing the line with eglot-ensure and using simply M-x eglot still reproduces the error?

mekeor commented 2 years ago

I tested it and confirm that removing the line with eglot-ensure and using simply M-x eglot still reproduces the error.

mekeor commented 2 years ago

max-specpdl-size is 1800 for me, btw.

mekeor commented 2 years ago

for the record: i further boiled down the mre.el code in the meantime. i hope you will be able to reproduce this error.

i wonder if this ticket really differs from https://github.com/joaotavora/eglot/issues/633 or if it's really just the same.

joaotavora commented 2 years ago

Alright! I reproduced it. I'm not sure what's causing the error, but it's not easy to get a backtrace. Also gopls is reporting some ginormous logMessage notifications.

joaotavora commented 2 years ago

The commit https://github.com/joaotavora/eglot/commit/fadf7594e93def4fc60d403441aa1812bcc1e38e should fix this issue, though I botched the commit message. Closing this tentatively, but let me know if the problem persists.

mekeor commented 2 years ago

@joaotavora: the changes seem to fix the issue for me. thank you very much for your efforts!