Emacs-D-Mode-Maintainers / Emacs-D-Mode

An Emacs mode for D code.
GNU General Public License v3.0
84 stars 22 forks source link

Freezing on loading specific file #55

Closed landaire closed 7 years ago

landaire commented 8 years ago

More context here: https://github.com/syl20bnr/spacemacs/issues/4196

spacemacs' d layer includes this package and for some reason when loading dmd's src/doc.d file I experience a hang/freeze. I've narrowed it down to the d layer specifically causing the issues and I think it may have something to do with this package.

MartinNowak commented 8 years ago

Same issue here, since I updated d-mode from 20150317.117 to 20151205.2354 I'm constantly experiencing freezes on certain files.

MartinNowak commented 8 years ago

You can break out of whatever infinite loop is causing this using C-g (keyboard-quit).

CyberShadow commented 8 years ago

It works for me, does it still happen for you?

If you pkill -SIGUSR2 emacs, what stack trace do you get in the debugger?

MartinNowak commented 8 years ago

If you pkill -SIGUSR2 emacs, what stack trace do you get in the debugger?

Debugger entered--entering a function:
* #[0 "\300?\205\301\302!\207" [t restore-buffer-modified-p nil] 2]()
  syntax-propertize(121589)
  internal--syntax-propertize(119589)
  parse-partial-sexp(118640 121640)
  c-state-semi-safe-place(264264)
  c-literal-limits()
  c-fl-decl-start(263347)
  c-context-expand-fl-region(263347 263847)
  #[(fn) " \n\"\211@A\211\207" [fn new-beg new-end new-region] 4](c-context-expand-fl-region)
  mapc(#[(fn) "    \n\"\211@A\211\207" [fn new-beg new-end new-region] 4] (c-context-expand-fl-region))
  c-before-context-fl-expand-region(263347 263847)
  c-font-lock-fontify-region(263347 263847 nil)
  font-lock-fontify-region(263347 263847)
  #[257 "\211\300\301\"\211\242\306=\203\211A\202\300\301B\211@A\211\302\211\242\206 e]\240\210\303\211\242\206+d^\240\210\304\211\242^\240\210\305\211\242]\240\210\307\266\202\207" [263347 263847 (nil) (nil) (263347) (263847) jit-lock-bounds nil] 10 "\n\n(fn FUN)"](font-lock-fontify-region)
  run-hook-wrapped(#[257 "\211\300\301\"\211\242\306=\203\211A\202\300\301B\211@A\211\302\211\242\206 e]\240\210\303\211\242\206+d^\240\210\304\211\242^\240\210\305\211\242]\240\210\307\266\202\207" [263347 263847 (nil) (nil) (263347) (263847) jit-lock-bounds nil] 10 "\n\n(fn FUN)"] font-lock-fontify-region)
  jit-lock--run-functions(263347 263847)
  jit-lock-fontify-now(263347 263847)
  jit-lock-function(263347)
  redisplay_internal\ \(C\ function\)()
CyberShadow commented 8 years ago

Actually I get this too. However, I can't reproduce it with that file. What file do you get it to freeze with?

MartinNowak commented 8 years ago

https://raw.githubusercontent.com/dlang/dmd/c41f00bd16297c5855ed21de72d2e63aa8fc08e5/src/expression.d at line 8334 (use revert-buffer while your cursor is in that area).

CyberShadow commented 8 years ago

Unfortunately I can't reproduce that (though I did encounter freezes with similar stack traces). Can you reproduce it every time?

I guess I'll be on the lookout for cases that I can reproduce.

MartinNowak commented 8 years ago

Yes every time, but only when the cursor or screen in around that line number.

MartinNowak commented 8 years ago

I guess I'll be on the lookout for cases that I can reproduce.

Let's turn it around then, how would you debug/fix the issue if you could reproduce it. Maybe I can fix it instead.

CyberShadow commented 8 years ago

Well, as far as I can tell, the stack trace is useless. It does contain point pairs that mark the region being fontified, but I have not found it to have any direct relevance to the freezes. At least, deleting everything but the code between the mentioned points did not allow me to reproduce the freeze, IIRC. It also doesn't mention (at least in a comprehensible way) which syntax rule / regular expression is causing the freeze.

What I would probably do is somehow rig it up with DustMite, and attempt to reduce it to the minimal code that makes Emacs freeze...

MartinNowak commented 8 years ago

I doesn't actually freeze but manages to continue after a long while. I could track it down to backtick (`) delimited words, either in a ddoc comment or as string. Emacs even freezes when typing in an existing backticks string. Maybe it's trying to match a backtick across many hundred lines?

CyberShadow commented 8 years ago

It's possible.

Make sure you're using the latest version, I fixed a bug with backticks and backslashes a while ago: https://github.com/Emacs-D-Mode-Maintainers/Emacs-D-Mode/pull/65

MartinNowak commented 8 years ago

I fixed a bug with backticks and backslashes a while ago:

A while ago is good ;), you fixed it while I was involved in this bug report.

Exclude the \ character from the character set excluding `. This was also causing fontification to take an exponential time, to a lesser degree.

Glad this was resolved w/ #65.

CyberShadow commented 8 years ago

FWIW, I haven't encountered this recently. Perhaps it was fixed in an Emacs update.

If someone has a reproducible test case, please post it.

MartinNowak commented 7 years ago

It was fixed by #65, should be closed.