Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lisp exceeds `max-lisp-eval-depth' #64

Closed
yizhang-yiz opened this issue Jan 29, 2021 · 11 comments · Fixed by #65
Closed

lisp exceeds `max-lisp-eval-depth' #64

yizhang-yiz opened this issue Jan 29, 2021 · 11 comments · Fixed by #65
Assignees
Labels

Comments

@yizhang-yiz
Copy link

Summary

It was driving me nuts and took me a while to narrow down to stan-mode but I'm still not 100% sure it's the cause of c++-mode losing all the highlighting and prompting

lisp exceeds `max-lisp-eval-depth'`

How to reproduce

use clean emacs init

rm -rf ~/.emacs.d; mkdir ~/.emacs.d

Add a minimalist init to ~/.emacs.d:

;; init.el

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Comment/uncomment this line to enable MELPA Stable if desired.  See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)

Test emacs with a c++ header

I use the following to test

// debug.cpp
#ifndef STAN_MATH_EVENT_HPP
#define STAN_MATH_EVENT_HPP

#include <stan/math/typedefs.hpp>
#include <stan/math/dsolve/ode_integrator.hpp>
#include <stan/math/mpi/precomputed_gradients.hpp>
#include <stan/math/model_solve.hpp>
#include<vector>

The file should be displayed normally:
Screen Shot 2021-01-29 at 1 22 35 PM

add stan-mode

M-x package-install RET stan-mode
close & reopen emacs.

Open a stan model

I use the vanilla bernoulli.stan
Screen Shot 2021-01-29 at 1 27 07 PM

open the c++ file and edit

Now open that c++ file and try to edit. For example, when I insert space, I'm getting (note the mini buffer)
Screen Shot 2021-01-29 at 1 25 34 PM
and now if I close that file and reopen it, all highlighting is gone
Screen Shot 2021-01-29 at 1 29 54 PM

OS

OS: mac os x 10.14.6 (18G7016)
Emacs: all 26.1-27.1 builds from https://emacsformacosx.com/builds

If I use builds from
https://vigou3.gitlab.io/emacs-modified-macos/
with same init.el and stan-mode installed when openning a stan file I'm getting
Screen Shot 2021-01-29 at 1 35 50 PM
and I'm assuming they are caused by a same issue.

@kaz-yos
Copy link
Collaborator

kaz-yos commented Jan 29, 2021

Thanks for the super-detailed report! I'll try to reproduce it

Meanwhile, can you M-x describe-face on the C++ code when the highlight is gone? This may help if the face definitions are affected vs assigning colors to them is affected.

Also if you could obtain the full trace with M-x debug-on-error, it'll be helpful.

@kaz-yos
Copy link
Collaborator

kaz-yos commented Jan 29, 2021

It does reproduce in my environment. I have not done a clean environment test, yet.

The face is of the non-highlighted text becomes default.

@yizhang-yiz
Copy link
Author

Meanwhile, can you M-x describe-face on the C++ code when the highlight is gone?

When it's normal it should be font-lock-preprocessor-face but when hl is gone I'm getting default.

Also if you could obtain the full trace with M-x debug-on-error, it'll be helpful.

I did use --init-debug but didn't see debugger popout when lisp-exceeds... issue occurs.

@kaz-yos
Copy link
Collaborator

kaz-yos commented Jan 29, 2021

Is it correct, if you add actual code (rather than headers starting with pound/hashtag #) you do get highlighted code?

@yizhang-yiz
Copy link
Author

When typing it's still under default face.

@kaz-yos
Copy link
Collaborator

kaz-yos commented Jan 29, 2021

The most likely culprit is the handling of # in stan-mode.

stan-mode is a derivative of C++ mode, but try to cover the role of # as a comment in the older version of stan as well as headers with some hack. This may be affecting other C++ related modes.

@kaz-yos
Copy link
Collaborator

kaz-yos commented Jan 29, 2021

In my regular environment, it looks like this.

Screen Shot 2021-01-29 at 17 05 18

Perhaps, the # part is losing the syntactical meaning as preprocessor and syntax highlighter is getting confused.

I am not a C++ savvy (or Stan in that regard), so could you provide me with a code example that includes both preprocessor part and actual C++ code. It'll be useful for automated testing (defining the correct behavior) and fixing this issue.

Dropping the old stan # comment support is likely the solution, which I will investigate.

@yizhang-yiz
Copy link
Author

https://github.com/stan-dev/stan/blob/develop/src/stan/mcmc/hmc/nuts/adapt_unit_e_nuts.hpp
This file has enough c++ gibberish & symbols.

IMO we'll be fine dropping old comment support if it solves the issue.

@kaz-yos
Copy link
Collaborator

kaz-yos commented Jan 29, 2021

Thanks! This will be very helpful. Even before things break, the ifndef line was not highlighted. Is this a usual behavior?

TODOs.

  1. Describe correct behaviors for the C++ syntax highlighting with a realistic code example (check faces before it breaks and define them as buttercup expectations; can save the entire string with face properties?).
  2. Test against these expectations before and after loading a stan file (The "after" test should fail).
  3. Drop the old # comment support to see if the above tests pass
  4. Drop corresponding old tests if other behaviors are preserved.

@yizhang-yiz
Copy link
Author

yizhang-yiz commented Jan 29, 2021

Thanks! This will be very helpful. Even before things break, the ifndef line was not highlighted. Is this a usual behavior?

yes.

kaz-yos added a commit to kaz-yos/stan-mode that referenced this issue Jan 30, 2021
- Fix interference with c++-mode stan-dev#64
kaz-yos added a commit to kaz-yos/stan-mode that referenced this issue Jan 30, 2021
- Fix interference with c++-mode stan-dev#64
@kaz-yos
Copy link
Collaborator

kaz-yos commented Jan 30, 2021

Developer note: There was an issue how c-syntactic-end-of-macro was advised to allow for special behavior in stan-mode (unintended nested calls?). Since this function is advised globally (no buffer-local advice functionality), it also affected c++-mode where it is also used to detect syntax for highlighting. The advice implementation was improved to avoid this interference issue.

Screen Shot 2021-01-30 at 06 03 06

TODOs

  1. Check Travis-CI status for passing
  2. Push to master (MELPA release)
  3. Tag with version 10.2.1 (MELPA-Stable release)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants