haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.66k stars 355 forks source link

Yesod project haskell-language-server crashes #1839

Closed DanielLiuCD closed 2 years ago

DanielLiuCD commented 3 years ago

Module "/Users/liu/my-project/a" is loaded by Cradle: Cradle {cradleRootDir = "/Users/liu/my-project", cradleOptsProg = CradleAction: Stack} Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.1.0.0, Git revision f1c096927186a93d8e3ccd4fe8385cc1b070350b (dirty) x86_64 ghc-8.10.4 Current directory: /Users/liu/my-project Operating system: darwin Arguments: ["--lsp","-d","-l","/var/folders/fh/69nshvzd2h98d99cmytnx9nm0000gn/T/hls.log"] Cradle directory: /Users/liu/my-project Cradle type: Stack

Tool versions found on the $PATH cabal: 3.2.0.0 stack: 2.5.1 ghc: 8.8.3

Consulting the cradle to get project GHC version... Project GHC version: 8.8.4 haskell-language-server exe candidates: ["haskell-language-server-8.8.4","haskell-language-server-8.8","haskell-language-server"] Launching haskell-language-server exe at:/Users/liu/bin/haskell-language-server-8.8.4 haskell-language-server version: 1.1.0.0 (GHC: 8.8.4) (PATH: /Users/liu/bin/haskell-language-server-8.8.4) (GIT hash: f1c096927186a93d8e3ccd4fe8385cc1b070350b) Starting (haskell-language-server)LSP server... with arguments: GhcideArguments {argsCommand = LSP, argsCwd = Nothing, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = True, argsLogFile = Just "/var/folders/fh/69nshvzd2h98d99cmytnx9nm0000gn/T/hls.log", argsThreads = 0, argsProjectGhcVersion = False} with plugins: [PluginId "pragmas",PluginId "floskell",PluginId "fourmolu",PluginId "tactics",PluginId "ormolu",PluginId "stylish-haskell",PluginId "retrie",PluginId "brittany",PluginId "class",PluginId "haddockComments",PluginId "eval",PluginId "importLens",PluginId "moduleName",PluginId "hlint",PluginId "splice",PluginId "ghcide-hover-and-symbols",PluginId "ghcide-code-actions",PluginId "ghcide-completions",PluginId "ghcide-type-lenses",PluginId "ghcide-core"] in directory: /Users/liu/my-project Starting LSP server... If you are seeing this in a terminal, you probably should have run WITHOUT the --lsp option! Started LSP server in 0.00s setInitialDynFlags cradle: Cradle {cradleRootDir = "/Users/liu/my-project", cradleOptsProg = CradleAction: Stack} Output from setting up the cradle Cradle {cradleRootDir = "/Users/liu/my-project", cradleOptsProg = CradleAction: Stack}

/Users/liu/my-project/my-project.cabal was modified manually. Ignoring /Users/liu/my-project/package.yaml in favor of the cabal file. If you want to use the package.yaml file instead of the cabal file, then please delete the cabal file. my-project> configure (lib) Configuring my-project-0.0.0... my-project> initial-build-steps (lib) Configuring GHCi with the following packages: my-project /Users/liu/my-project/my-project.cabal was modified manually. Ignoring /Users/liu/my-project/package.yaml in favor of the cabal file. If you want to use the package.yaml file instead of the cabal file, then please delete the cabal file. /Users/liu/my-project/my-project.cabal was modified manually. Ignoring /Users/liu/my-project/package.yaml in favor of the cabal file. If you want to use the package.yaml file instead of the cabal file, then please delete the cabal file. /Users/liu/my-project/.stack-work/install/x86_64-osx/f6a232d83d449e5e8baeb16c34e9f47b1240ae93d3391c7bec44ec7e80826d24/8.8.4/pkgdb:/Users/liu/.stack/snapshots/x86_64-osx/f6a232d83d449e5e8baeb16c34e9f47b1240ae93d3391c7bec44ec7e80826d24/8.8.4/pkgdb:/Users/liu/.stack/programs/x86_64-osx/ghc-8.8.4/lib/ghc-8.8.4/package.conf.d haskell-language-server-wrapper: callProcess: /Users/liu/bin/haskell-language-server-8.8.4 "--lsp" "-d" "-l" "/var/folders/fh/69nshvzd2h98d99cmytnx9nm0000gn/T/hls.log" (exit -11): failed

my-project.zip

mkasa commented 3 years ago

Not 100% sure if this is related or not, though I also have an issue with yesod/sqlite. It is reproducible with the stack yesod template and with Ubuntu 20.04.2 LTS and Haskell Language Server 1.1.0 binary releases.

ubuntu@vbox1:~/work$ stack new foo yesodweb/sqlite
(snip)
ubuntu@vbox1:~/work$ cd foo
ubuntu@vbox1:~/work/foo$ stack build
(build succeeds)
ubuntu@vbox1:~/work/foo$ stack exec -- haskell-language-server-wrapper
(snip)
2021-05-29 21:07:26.091060431 [ThreadId 1437] INFO hls: File:     /home/ubuntu/work/foo/src/Settings/StaticFiles.hs
Hidden:   no
Range:    1:1-2:1
Source:   typecheck
Severity: DsError
Message:
  Program error:
  ByteCodeLink.lookupCE
  During interactive linking, GHCi couldn't find the following symbol:
  persistentzmsqlitezm2zi10zi6zi2zmSdWMygXJXX8YNCiPu2ZZe0_DatabaseziPersistziSqlite_zdfFromJSONSqliteConf_closure
  This may be due to you not asking GHCi to load extra object files,
  archives or DLLs needed by your current session. Restart GHCi, specifying
  the missing library using the -L/path/to/object/dir and -lmissinglibname
  flags, or simply by naming the relevant files on the GHCi command line.
  Alternatively, this link failure might indicate a bug in GHCi.
  If you suspect the latter, please send a bug report to:
  glasgow-haskell-bugs@haskell.org
2021-05-29 21:07:26.146750845 [ThreadId 1549] INFO hls: finish: User TypeCheck (took 0.83s)
2021-05-29 21:07:26.147203026 [ThreadId 1552] INFO hls: finish: GetHie (took 0.00s)
Files that failed:
2021-05-29 21:07:26.147679369 [ThreadId 1561] INFO hls: finish: GenerateCore (took 0.00s)
 * /home/ubuntu/work/foo/app/devel.hs
 * /home/ubuntu/work/foo/src/Application.hs
 * /home/ubuntu/work/foo/src/Foundation.hs
 * /home/ubuntu/work/foo/src/Import.hs
 * /home/ubuntu/work/foo/src/Handler/Comment.hs
 * /home/ubuntu/work/foo/src/Handler/Common.hs
 * /home/ubuntu/work/foo/src/Handler/Home.hs
 * /home/ubuntu/work/foo/src/Handler/Profile.hs
 * /home/ubuntu/work/foo/src/Import/NoFoundation.hs
 * /home/ubuntu/work/foo/src/Settings/StaticFiles.hs

Completed (10 files worked, 10 files failed)
haskell-language-server-8.8.4: allocatestack.c:384: advise_stack_range: Assertion `freesize < size' failed.
haskell-language-server-wrapper: callProcess: /home/ubuntu/.local/bin/haskell-language-server-8.8.4 (exit -6): failed

After I saw the last assertion error, I tried to reproduce it with macOS, but on macOS, stack build did not succeed, so I gave up.

Next, I changed the Stackage version to lts-17.13 (ghc-8.10.4). I added allow-newer: True, and modified the source code a bit to make it compile (added LANGUAGE pragma as suggested by the compiler, removed devel.hs). The link error disappeared but it fails with the same assertion error (the last three lines shown below).

Completed (19 files worked, 0 files failed)
haskell-language-server-8.10.4: allocatestack.c:384: advise_stack_range: Assertion `freesize < size' failed.
haskell-language-server-wrapper: callProcess: /home/ubuntu/.local/bin/haskell-language-server-8.10.4 (exit -6): failed
lulin commented 2 years ago

I got the same issue. OS: ubuntu20.04, haskell-language-server: 1.5.1, installed by ghcup, ghc: 8.8.4

lsp-haskell::stderr:

Found "/home/lulin/projects/summersun/hie.yaml" for "/home/lulin/projects/summersun/a" Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.5.1.0, Git revision 745ef26f406dbdd5e4a538585f8519af9f1ccb09 (dirty) x86_64 ghc-8.10.7 Current directory: /home/lulin/projects/summersun Operating system: linux Arguments: ["--lsp","-d","-l","/tmp/hls.log"] Cradle directory: /home/lulin/projects/summersun Cradle type: Stack

Tool versions found on the $PATH cabal: 3.6.2.0 stack: 2.7.3 ghc: 8.10.7

Consulting the cradle to get project GHC version... Project GHC version: 8.8.4 haskell-language-server exe candidates: ["haskell-language-server-8.8.4","haskell-language-server"] Launching haskell-language-server exe at:/home/lulin/.ghcup/bin/haskell-language-server-8.8.4 haskell-language-server version: 1.5.1.0 (GHC: 8.8.4) (PATH: /home/lulin/.ghcup/bin/haskell-language-server-8.8.4~1.5.1) (GIT hash: 745ef26f406dbdd5e4a538585f8519af9f1ccb09) Starting (haskell-language-server)LSP server... with arguments: GhcideArguments {argsCommand = LSP, argsCwd = Nothing, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = True, argsLogFile = Just "/tmp/hls.log", argsThreads = 0, argsProjectGhcVersion = False} with plugins: [PluginId "pragmas",PluginId "floskell",PluginId "fourmolu",PluginId "tactics",PluginId "ormolu",PluginId "stylish-haskell",PluginId "retrie",PluginId "brittany",PluginId "callHierarchy",PluginId "class",PluginId "haddockComments",PluginId "eval",PluginId "importLens",PluginId "refineImports",PluginId "moduleName",PluginId "hlint",PluginId "splice",PluginId "ghcide-hover-and-symbols",PluginId "ghcide-code-actions-imports-exports",PluginId "ghcide-code-actions-type-signatures",PluginId "ghcide-code-actions-bindings",PluginId "ghcide-code-actions-fill-holes",PluginId "ghcide-completions",PluginId "ghcide-type-lenses",PluginId "ghcide-core"] in directory: /home/lulin/projects/summersun haskell-language-server-wrapper: callProcess: /home/lulin/.ghcup/bin/haskell-language-server-8.8.4 "--lsp" "-d" "-l" "/tmp/hls.log" (exit -11): failed

Process lsp-haskell stderr finished

mkasa commented 2 years ago

Just for your information. Rather than downloading the binary and using it,I tried compiling it from the source code, then the errors went away (for my case). I have no idea why it works, though.

jneira commented 2 years ago

Just for your information. Rather than downloading the binary and using it,I tried compiling it from the source code, then the errors went away (for my case). I have no idea why it works, though.

Hi, thanks for confirming it, i think it is related with the use of th and linking issues so it confirms the troubleshooting guide: https://haskell-language-server.readthedocs.io/en/latest/troubleshooting.html#static-binaries

risingBirdSong commented 2 years ago

HLS rarely works with Yesod for me so I tried this little test by not using the Yesod Template, instead just using plain Stack and I was pleasantly surprised to see HLS working.

https://github.com/risingBirdSong/yesodHLStest

maybe give it a try and see if it works for you?

jneira commented 2 years ago

I am gonna close this issue as all compiler crashes seems to have the same root cause:

If any of you think the issue should not be included generically feel free to reopen it (with a brief explanation if possible) Thanks all!