-
-
Notifications
You must be signed in to change notification settings - Fork 389
Segfault using TemplateHaskell (NixOs, MacOs for now) #277
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
Comments
I can't reproduce this with HLS built from source on mac, going to try with the 0.2.2 binary |
I can't reproduce it with the 0.2.2 binary either, with this file: {-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Polysemy
import Polysemy.Reader
data MyEffect m a where
Test :: m a -> MyEffect m a
makeSem ''MyEffect and with polysemy-1.3.0.0 on ghc-8.10.1. What version of GHC are you using? Can you pass on any of the logs too? |
This is ghc 8.4.4 (from a haskell.nix setup). There was a previous bug about Template Haskell incompatibilities at input-output-hk/haskell.nix#400 but that's been fixed for a while. If you have nix installed, you should be able to create the environment with I can also look at getting something from lldb, though it's been a while (and different language) ago 😅 If the answer is that haskell-language-server doesn't support this use case, it's not too bad as long as ghcide continues to work (this is the extant working system that we can fall back to); in this case, ghcide is compiled against the nix environment's ghc. Basic info from lldb (not knowing what I'm doing):
Log messages:
|
And tried with 0.2.2, same error; version is:
|
Hm those logs don't look good, not sure why its setting up a cradle multiple times for the same file. I've never used nix before but I think its about time I install it to see what's going on... |
|
Took a while to build without the caches, but I can recreate it now. Time to figure out what's going on |
I'm also facing the same problem on NixOS, using HLS 0.3.0.0 with GHC 8.8.3 (and 8.8.4). The source file is the same (hello world with logs
|
Same issue when using freer-simple's |
What type of cradle ( There is a possibly related TH idempotency bug in ghcide that @maralorn is investigating. |
Just a single cradle with a single component (executable). The correct settings are auto-detected, but here's the
|
Does your Cabal descriptor consist of only one executable stanza, or also a library stanza? |
I've tried with the following setups: Nix setups:
ghcup:
|
Thanks for testing! We have previously found bugs with ghc 8.8.4 that didn't arise with 8.10. Hereby closing as won't fix |
I still get the segfault using GHC 8.10.2, with a single executable stanza, and any TH function invocation.
habit.cabal
src/Main.hs{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TemplateHaskell #-}
module Main where
import HaskellSay (haskellSay)
import Data.Text (Text)
import Control.Monad.Freer (Eff, Member, send)
import Control.Monad.Freer.TH
data Console r where
PutTextLn :: Text -> Console ()
makeEffect ''Console
-- putTextLn :: Member Console effs => Text -> Eff effs ()
-- putTextLn = send . PutTextLn
main :: IO ()
main = haskellSay "Hello, Haskell! You're using a function from another module!" Please reopen the issue. |
I will reopen, i think we have to tackle the problems with template haskell as a whole, there is several issues about |
@Galagora for completeness: the error you got with that minimal case is using NixOs and the same output as #277 (comment)? |
ghcide issues involving th and segfaults: |
Yes, except the last line is:
instead of
Which is probably just a platform difference. |
OK, so, for me at least, the bug seems to have nothing to do with
ghcide logs
hello.cabal
src/TH.hs{-#LANGUAGE TemplateHaskell#-}
module TH
(
thLit
-- , thFunc
-- , thFTyped
)
where
import Language.Haskell.TH
thLit :: Q Exp
thLit = [| 15 |]
-- thFunc :: Q Exp
-- thFunc = [| \x -> x + 1|]
-- thFTyped :: Q (TExp (Integer -> Integer))
-- thFTyped = [|| \y -> y + 1 ||] src/Main.hs{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Debug.Trace
import TH
main :: IO ()
main = do
print ($(thLit) :: Integer)
hie.yamlcradle:
cabal:
- path: "./src/Main.hs"
component: "hello:exe:hello"
- path: "./src/TH.hs"
component: "hello:exe:hello" That's pretty much the smallest piece of Template Haskell you can write. |
@pepeiborra Why is a |
@Galagora wow, many thanks for minimize the repro case and report all the logs |
@jneira Yeah, no problem. Two things though:
Currently, I'm trying to build and test the version of |
Yeah, the issue probably belongs to ghcide. The branch of ghcide used in hls is supposed to be merged onto ghcide master and it has not much diverged commits so i would test ghcide master first, it would isolate the cause in those commits. Agree in pinning the issue so the use of TH is persasive, not sure it it does not work for all cases. sure @wz1000 and @pepeiborra could help you to find the root cause better than me though 😉 |
The issue is actually fixed as of the latest |
@fiadliel i am gonna close this one, feel free to reopen if you continue experiencing the issue |
@Galagora I'm also getting a |
With ghc-8.10.{3,4}, the issue is likely is a ghc bug, you should either downgrade to ghc-8.10.2 or wait for ghc-8.10.5 |
Thanks for the quick response. I downgraded, but the error is exactly the same :( |
Also for the record, the build ( |
You can reproduce it with You can also try using the dynamic linker to compile ghcide (see https://cabal.readthedocs.io/en/3.4/cabal-project.html?highlight=dynamic#cfg-field-executable-dynamic).
That doesn't really say much, the bug is a race condition which is triggered by large programs being compiled in parallel (which is exactly the strategy ghcide uses). |
It's a school project so dear professor, if you read this please don't hit me with them plagiarism, https://git.science.uu.nl/h.a.peters/afp-querybuilder. I think master might me broken, but I'll try to fix it first thing tomorrow |
Master is now fixed in the above project! I am working on the same project as @HugoPeters1024 |
In a simple project with polysemy included, the addition of the
makeSem
call into Template Haskell causes HLS to crash reliably (segmentation fault). With themakeSem
line commented out, the plugin starts correctly.e.g.
A repository that should demonstrate the issue is at https://github.com/fiadliel/effects
The text was updated successfully, but these errors were encountered: