-
Notifications
You must be signed in to change notification settings - Fork 206
Weird crash on a module importing th definitions that runs IO #1480
Comments
Weird indeed! |
Hmm, I found what breaks it. Here's how to reproduce: module module TH where
import Data.Aeson (Value)
import Data.Yaml (decodeFileThrow)
import Language.Haskell.TH (Exp, Q, runIO)
import Language.Haskell.TH.Syntax (addDependentFile, lift)
loadEnum :: FilePath -> Q Exp
loadEnum path = do
val <- runIO $ decodeFileThrow path :: Q Value
lift ([] :: [String]) module {-# LANGUAGE TemplateHaskell #-}
module Exp where
import TH
list :: [String]
list = $(loadEnum "test.txt") file 123
456 With this I get the same behavior on |
Maybe it's worth noting that I first observed this on a module that just imports list defined in Exp.hs, therefore I had no idea that the problem is in TH. |
Thanks for investigating and minimize the reproduction case. |
Yes, looks like that. Where do you think the problem is -- in hie, ghc-mod or maybe ghc itself? |
I think the problem is that we work with a copy of the file in a temporary directory. I suspect it is not able to find the file "test.txt". |
@alanz sadly, it's probably more complicated than that. Here's what I checked:
So probably the problem is somewhere in that module: http://hackage.haskell.org/package/yaml-0.11.2.0/docs/src/Data.Yaml.html That's totally crazy. |
I checked if i fails with latest snoyberg/yaml@d0a2ba62a (yaml-0.11.2.0) -- it does. I tried with I was able to find a place in If I change the function to: runParser parser = do
let mark = YamlMark 0 0 0
yield $ MarkedEvent EventStreamStart mark mark
yield $ MarkedEvent EventDocumentStart mark mark
yield $ MarkedEvent (EventScalar (B8.pack "!!!!") NoTag Plain Nothing) mark mark
yield $ MarkedEvent EventDocumentEnd mark mark
yield $ MarkedEvent EventStreamEnd mark mark
return () -- i.e. return constant yaml without actually parsing file (but still with opening, initing C library and freeing it afterwards). And in this case, HIE does not crash. Is there any option or patch to make HIE output when or how exactly does ghc-mod fail? |
Hello. FYI, this still happens on latest master (92ac896). Now HIE does not crash, it just doesn't work. There is this line in the log:
After that, judging by the log, it gets my commands like "hover", but does not answer. Full log with How can I debug this further/ |
The issue you are encountering looks like #1520 and currently, there is not much to debug it. The problem might occur on Modules that import |
Well, I don't know if the two are related. I found out that my issue is related to using "yaml" package - see above for proof. It is some weird interaction between yaml, its ffi stuff, TH and hie. |
The error also reminds me #1207 |
The cabal project loading stops in |
Just ran into this in a Yesod Application. The standard |
I too am having issues on a Yesod Application, but I can't tell which file it's crashing on based on the log output. |
Sadly, this still happens with latest master (35f62cf), LTS-15.5 and GHC-8.8.3. |
I am also experiencing this issue with some TH code that performs IO. I managed to get 2 different crash messages:
|
Well, at least I don't feel alone, as I am also experiencing the |
hie works fine on all modules in my project except one. I see this in logs (
--debug --vomit
):As you can see, hie (ghc-mod?) just dies without printing any logs. Unfortunately, I can't share my code as this is a private project at my job.
Can you give any hints on how to get more info from hie?
I tried removing some code from the module, but wasn't able to find minimal offending piece...
I'm on latest master (f7e0db0) with GHC-8.6.3, my project uses LTS-13.6 from stack. I use nvim with coc.nvim.
The text was updated successfully, but these errors were encountered: