Emacs hangs on hovering on the comments in the big Haskell files
Anton-Latukha opened this issue · 6 comments
Headpost updates to the current status results of the discussion
I believe the #1747 & #1661
and probably #1751
have in common the problem of a computational data spike during the file representation, especially correlating with comments.
It is not 100% it is a haskell-mode
fault, but it is the closest entity currently.
I have 100% reproducible hang in some large files - directly in the moment of hovering over comments during haskell-mode
enabled:
Observe syndrome behaviour
- On smaller files -
haskell-mode
works normally.
(Notice what haskell-mode
does on comment selection at the end of it (selects the whole file):)
- Now, lets open a larger file:
Bigger file
Sorry for the somewhat longish GIF file, it took numerous attempts of initial selection positioning (to not hang Emacs right away) and so numerous Emacs restarts to somewhat properly record and show this behavior.
My symbol map (pretty-symbols-mode
) does not matter - the hang happens regardless of it.
So Emacs hangs on selecting comments on big files. During hover over any comment - haskell-mode
tries to select the whole file, overflows something, and never arrives at showing the selection or minibuffer.
I have small Emacs skill, but would try to pinpoint the issue to:
It happens between:
lsp-ui-doc--extract
font-lock-fontify-region
markdown-fontify-code-blocks-generic
With the last one calling the compiled bytecodematch-data
set-match-data 'evaporate
which hangs. When functions were not compiled - I several times saw the huge fields of mangled (one time it was obvious, instead of markup/command language I observed lines upon lines of a mesh of repeating(1)(1)...
(2)(2)...
data) data fed into it.
And because of that overflow of data the thread goes into infinite processes.
Debugging information:
- Regardless of Emacs version (the same behavior in both 27.2, 28.0.50)
- Regardless of trying for 2-4 month old checkouts of
{lsp-mode, lsp-haskell, haskell-mode, markdown-mode}
. Maybe I missed something there, but they versions are not important, the selection of the whole file - is. - My configuration is somewhat complex, but it has already settled for ~ year and lately I was not changing it much at all. Trying to reshuffle the configurations were unsuccessful, the same behavior all the time.
So far despite of efforts, I can not track the problem deeper. From all modes (packages) mentioned, only when haskell-mode
is turned off - then Emacs works normally in large Haskell files, but at that point - there is no Haskell functionality there.
An example of a project/file when it happens 100% of the time is - https://github.com/haskell-nix/hnix Nix.Expr.Types
module, but got the hang in other big Haskell files also.
What we can do to observe the problem more closely, and stop haskell-mode
from selecting the whole file while the mouse or keyboard hovers on comments.
Thanks. I'm not aware that haskell-mode has any behaviour that causes it to mark regions while hovering, let alone the whole file, so it sounds like some pathological behaviour of - or interaction with - lsp-mode
.
I also was thinking that it is lsp-mode
or lsp-haskell
before arriving here.
And was puzzled that projects do not have relevant reports or search on the topic giving results.
More precisely - the bug seems to be related closely to lsp-ui
.
To its lsp-ui-doc
component.
lsp-ui
bug reports are ridden with reports on lsp-ui-doc
, which seems like a lovely place to fix a bunch of stuff at once.
Sadly I as user can not transfer the report to proper place.
Further would delete all elc
s and run on ELisp to get better profile-{start, stop, report}
, until can pinpoint the cause. As you see - someone also found this thread here useful. So until bug cause is pinpointed - I can not move the discussion into the proper place, since I do not know the place.
I going to bisect on lsp-ui
or get a relevant response there and then probably close this report.
I've tracked over ELisp code.
I've tracked it down into it.
It is HLS (Haskell Language Server) problem. It wrongly selects the scopes.
In other editors - the selection behavior is the same, but in Emacs that selection causes a hang in large files.
Thanks for digging into that and following up here.
Well, HLS is a pretty complex piece of software.
Moreover my Emacs setup is being flaky.
Moreover, it is not that easy to bootstrap/debug/test HLS.
It can take quite a while to figure-out how where what and to fix it there, but I began looking.