atom-haskell-archive / haskell-ghc-mod

haskell-ghc-mod atom package
https://atom.io/packages/haskell-ghc-mod
MIT License
69 stars 20 forks source link

Opening atom in a Haskell project with this package enabled freezes editor #238

Closed LukaHorvat closed 6 years ago

LukaHorvat commented 6 years ago

The editor freezes and there's an atom process that uses 100% of one core and fills up the memory until the PC crashes.

Running something like stack exec ghc-mod -- check path/to/file.hs works fine. When I run the editor with this package disabled everything is fine.

Windows 10, Atom 1.25.0-beta2, latest version of all related Haskell packages. ghc-mod version doesn't seem to matter since it happens in both a GHC 8.0.2 and GHC 8.2.2 projects with locally installed ghc-mod.

Here's the console log before the editor froze.

lierdakil commented 6 years ago

Try disabling autocomplete-haskell and language-haskell-scoped instead of haskell-ghc-mod if you have any of those installed and see if that helps.

... because at the moment, I have literally no idea what's going on.

LukaHorvat commented 6 years ago

Yep, it was the scoped package that did it. Seems to work fine with it disabled!

lierdakil commented 6 years ago

Hmm. So it's either scoped's highlighter code that does something wrong, or autocompletion backend.

Does autocompletion work? (assuming autocomplete-haskell is enabled, language-haskell-scoped is disabled, haskell-ghc-mod is enabled)

LukaHorvat commented 6 years ago

Yep, autocomplete works.

lierdakil commented 6 years ago

I tried to reproduce on Win7 (I don't have Win10 handy at the moment) with Atom 1.25.0-beta2 and was unsuccessful. So either this is Win10-specific (which is doubtful), or there are some other variables here. Any insight? 'Cause I'm a bit lost.

YotaVGA commented 6 years ago

I've a really similar problem with atom 1.27.2 and win 10. When language-haskell-scoped is enabled, when I do some specific modifications or open a file with that modifications all freezes when ghc-mod is loading (the hourglass is showed in the IDE-Haskell panel). In particular it seems that atom freezes are somewhat related to non correct indentations or white lines in between of indented blocks, but for now I don't have a specific schema. However it seems to happens always with the same modifications and the same patterns. For example, if I add a "where" clause, write some indented functions after that (from the very next line after the "where"), and then add a white line after "where" it freezes. Since I disabled language-haskell-scoped it seems to works correctly, even if I have not done so many tries for now.

lierdakil commented 6 years ago

@YotaVGA, a detailed reproduction guide would be very useful. I wasn't able to reproduce this myself.

YotaVGA commented 6 years ago

Ok, this is a really simple test you can do (one of the simpler ones I discovered that freezes my atom): Create a new, empty, .hs file (for example I called mine "test.hs".)

Paste this content inside of it :

main :: IO () main = putStrLn "Hello, World!"

Save (I don't think it is important, but I've done it.)

Now select the entire first row and press del to erase it.

If language-haskell-scoped is disabled all works fine. If it is enabled Atom freezes, you can still open menus but they don't do anything, atom doesn't respond in any way and after some time windows will suggest to close atom because is not responsive.

lierdakil commented 6 years ago

I was able to reproduce on Windows using the instructions given. Thanks.

After trying to debug it for some time, I ultimately managed to pinpoint the issue to superstring implementation of text buffer (specifically, regex search in text buffer using findAllInRange/findAllInRangeSync). Implementation apparently goes into an infinite allocation loop under some rather specific conditions which I couldn't determine precisely. I'll try to figure out what exactly is going wrong there if I find the time.

However, I believe I was able to work around the issue. The last version of language-haskell-scoped, namely v0.1.1, (hopefully) shouldn't cause these hangs anymore.

lierdakil commented 6 years ago

The underlying issue was fixed upstream, and the fix is slated for release with Atom v1.30.0. Not aware of any plans to backport it, but that can happen as well. I believe this issue can be closed. Feel free to let me know if you disagree.