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

Hangs when opening files with jinja string concatenation #3

Closed
wwentland opened this issue May 15, 2017 · 7 comments
Closed

Hangs when opening files with jinja string concatenation #3

wwentland opened this issue May 15, 2017 · 7 comments

Comments

@wwentland
Copy link

Dear Maintainer,

unfortunately emacs seems to hang if you open the following file:

baz:
  bar: {{ 'boo' ~ 'foo' }}

This seems to be only triggered if string literals are present as the following does not cause emacs to hang:

{% set boo = 'boo' %}
{% set foo = 'foo' %}

baz:
  bar: {{ boo ~ foo }}

Thank you!

@glynnforrest
Copy link
Owner

Thanks for the report, I can reproduce this. It completely locks emacs...

I'll try and get some time soon to look into this. In the meantime, if you're able to reproduce this with any other code, please post it here.

@glynnforrest
Copy link
Owner

I believe this crash is caused by python-mode syntax highlighting (which is the mode used inside jinja {{ }} tags).

Can you try the following?

  • Open an empty file with python-mode enabled
  • Insert 'foo' ~ 'bar'
  • Then (try to) insert a space at the start of the line. Emacs hangs immediately for me, then proceeds to blast the CPU, even after the buffer is closed.

See also dgutov/mmm-mode#66, where python-mode also hangs emacs due to malformed syntax.

I suppose fixing this bug in python-mode isn't going to be straightforward. I propose we try one of the following:

  • Switch the mode used inside {{ }} and {% %} tags to something simple like text-mode. We will lose some syntax highlighting and any specific python mode niceties.
  • Leave things as they are, since python-mode used in any way will hang on this kind of syntax, not just in salt-mode.
  • Create some kind of hook in salt mode that scans the buffer for bad regexes and attempts to change them, else disables the python submode. For example, I think {{ 'foo' ~ 'bar' }} could be changed to {{'foo' ~ 'bar'}} and python-mode won't explode. This of course has the downside of salt-mode changing your code in unexpected ways. I also suspect there are more of these python-mode syntax bugs that salt-mode would need to look for.

What do you think?

@dgutov
Copy link

dgutov commented May 15, 2017

I believe this crash

Is it a crash or a freeze?

@glynnforrest
Copy link
Owner

@dgutov a freeze I think?

It's an infinite loop in python-mode font locking according to your comment here dgutov/mmm-mode#66 (comment)

However I am unable to use C-g to recover from this, I have to kill emacs.

@dgutov
Copy link

dgutov commented May 15, 2017

It's an infinite loop in python-mode font locking according to your comment here

The relevant bug seems fixed (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24856#8). You might want to try to build Emacs from master, to double-check.

@glynnforrest
Copy link
Owner

@dgutov thank you for finding that out for me.

I just ran emacs from master and it doesn't have this bug, so I guess it's just a matter of time until this issue is fixed naturally. Thank you.

@wwentland
Copy link
Author

wwentland commented May 16, 2017

I can confirm that the bug has been fixed in emacs master and 25.2. Thank you for looking into this!

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

No branches or pull requests

3 participants