Skip to content
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

HLS keeps crashing (exit code -11, segfault, bus error, ..) with plutus pioneer program #1847

Closed
tdiesler opened this issue May 20, 2021 · 16 comments
Labels
can-workaround type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@tdiesler
Copy link

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

haskell-language-server version: 1.1.0.0 (GHC: 8.10.4) (PATH: .../.ghcup/bin/haskell-language-server-wrapper-1.1.0) (GIT hash: f1c096927186a93d8e3ccd4fe8385cc1b070350b)
Tool versions found on the $PATH
cabal:		3.4.0.0
stack:		2.5.1
ghc:		8.10.4

Which OS do you use: MacOS

Which lsp-client do you use: Atom

Cardano - Plutus Pioneer Program
https://github.com/tdiesler/plutus-pioneer-program/tree/mystuff/code

Contents of hie.yaml:

cradle:
  cabal:
    - path: "./src"
      component: "lib:plutus-proj01"

Steps to reproduce

Open any file in Atom e.g.
https://github.com/tdiesler/plutus-pioneer-program/blob/mystuff/code/proj01/src/Proj01/Counter1.hs

Actual behaviour

Atom repeatedly reports haskell-language-server crash - then gives up.

Include debug information

Execute in the root of your project the command haskell-language-server --debug . and paste the logs here:

...
File:     /Users/tdiesler/git/plutus-pioneer-program/code/proj01/src/Proj01/Types.hs
Hidden:   no
Range:    235:12-235:78
Source:   typecheck
Severity: DsWarning
Message: 
  • The constraint ‘HasType
  Plutus.Contract.Effects.WriteTx.TxSymbol
  Plutus.Contract.Effects.WriteTx.WriteTxResponse
  (Plutus.Contract.Schema.Input s)’ matches
  instance forall k (r :: row-types-1.0.1.0:Data.Row.Internal.Row k)
  (l :: ghc-prim-0.6.1:GHC.Types.Symbol) (a :: k).
  ((r row-types-1.0.1.0:Data.Row.Internal..! l)
  row-types-1.0.1.0:Data.Row.Internal.≈ a) =>
  HasType l a r
  -- Defined in ‘row-types-1.0.1.0:Data.Row.Internal’
  This makes type inference for inner bindings fragile;
  either use MonoLocalBinds, or simplify it using the instance
  • In the type signature:
  logMyTx :: (HasBlockchainActions s) =>
  String -> MyTx -> Contract w s Text ()
File:     /Users/tdiesler/git/plutus-pioneer-program/code/proj01/src/Proj01/Types.hs
Hidden:   no
Range:    241:15-241:18
Source:   typecheck
Severity: DsWarning
Message:  Defined but not used: ‘pad’
File:     /Users/tdiesler/git/plutus-pioneer-program/code/proj01/src/Proj01/Types.hs
Hidden:   no
Range:    248:16-248:19
Source:   typecheck
Severity: DsWarning
Message:  Defined but not used: ‘pad’
haskell-language-server-wrapper: callProcess: /Users/tdiesler/.ghcup/bin/haskell-language-server-8.10.4 "--debug" (exit -11): failed
@jneira jneira added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. type: setup labels May 20, 2021
@jneira
Copy link
Member

jneira commented May 20, 2021

Hi, thanks for the nice bug report.
If you run directly the command reported (/Users/tdiesler/.ghcup/bin/haskell-language-server-8.10.4 "--debug") in the cli, does it gives more details (in addition to the returned error code -11) about the error?

For completeness, when you use "keeps" do you want to mean that previous versions of hls has been failing in the past?

@jneira jneira added status: needs repro status: needs info Not actionable, because there's missing information labels May 20, 2021
@tdiesler
Copy link
Author

Here you go ...

$ /Users/tdiesler/.ghcup/bin/haskell-language-server-8.10.4 "--debug" 2> hls-crash-debug.txt
Segmentation fault: 11

hls-crash-debug.txt

At first, it worked great and I learned a lot from the linting hints. Lately however, hls keeps crashing and I see a lot of annoying popups and no more useful hints. I installed my Haskell env with ghcup.

hls keeps crashing

Atom makes repeated attempts to run HLS - they crash repeatedly - then Atom gives up.

@tdiesler
Copy link
Author

This forum post might be related ...

https://forum.cardano.org/t/setting-up-hls-on-macos-for-plutus-development/57729

@hududed
Copy link

hududed commented May 22, 2021

I may be facing a similar problem. I am running macOS 11.3.1. For the first few lessons, the HLS works well, but from lesson 4 onward HLS attempts to run 3-4 times, and it stops with the error message

[coc.nvim] The "languageserver.haskell" server crashed 5 times in the last 3 minutes. The server will not be restarted.

❯ haskell-language-server-wrapper --probe-tools
haskell-language-server version: 1.1.0.0 (GHC: 8.10.4) (PATH: /Users/hud/.ghcup/bin/haskell-language-server-wrapper-1.1.0) (GIT hash: f1c096927186a93d8e3ccd4fe8385cc1b070350b)
Tool versions found on the $PATH
cabal:		3.4.0.0
stack:		2.5.1.1
ghc:		8.10.2
❯ ~/.ghcup/bin/haskell-language-server-8.10.2 "--debug"
haskell-language-server version: 1.1.0.0 (GHC: 8.10.2) (PATH: /Users/hud/.ghcup/bin/haskell-language-server-8.10.2~1.1.0) (GIT hash: f1c096927186a93d8e3ccd4fe8385cc1b070350b)
 ghcide setup tester in /Users/hud/plutus-pioneer-program/code/week07.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in /Users/hud/plutus-pioneer-program/code/week07
Found 5 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
  (/Users/hud/plutus-pioneer-program/code/week07/hie.yaml)

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
2021-05-22 11:12:54.061442 [ThreadId 4] DEBUG hls:	Set files of interest to: [(NormalizedFilePath "/Users/hud/plutus-pioneer-program/code/week07/src/Week07/EvenOdd.hs",OnDisk),(NormalizedFilePath "/Users/hud/plutus-pioneer-program/code/week07/src/Week07/Test.hs",OnDisk),(NormalizedFilePath "/Users/hud/plutus-pioneer-program/code/week07/src/Week07/Homework.hs",OnDisk),(NormalizedFilePath "/Users/hud/plutus-pioneer-program/code/week07/src/Week07/StateMachine.hs",OnDisk),(NormalizedFilePath "/Users/hud/plutus-pioneer-program/code/week07/src/Week07/TestStateMachine.hs",OnDisk)]
2021-05-22 11:12:54.063035 [ThreadId 35] DEBUG hls:	hlint:getIdeas:file:NormalizedFilePath "/Users/hud/plutus-pioneer-program/code/week07/src/Week07/Test.hs"
2021-05-22 11:12:54.063234 [ThreadId 25] DEBUG hls:	hlint:getIdeas:file:NormalizedFilePath "/Users/hud/plutus-pioneer-program/code/week07/src/Week07/Homework.hs"
2021-05-22 11:12:54.063319 [ThreadId 32] DEBUG hls:	hlint:getIdeas:file:NormalizedFilePath "/Users/hud/plutus-pioneer-program/code/week07/src/Week07/EvenOdd.hs"
2021-05-22 11:12:54.063314 [ThreadId 29] DEBUG hls:	hlint:getIdeas:file:NormalizedFilePath "/Users/hud/plutus-pioneer-program/code/week07/src/Week07/StateMachine.hs"
2021-05-22 11:12:54.063307 [ThreadId 30] DEBUG hls:	hlint:getIdeas:file:NormalizedFilePath "/Users/hud/plutus-pioneer-program/code/week07/src/Week07/TestStateMachine.hs"
2021-05-22 11:12:54.064064 [ThreadId 40] INFO hls:	Consulting the cradle for "src/Week07/Homework.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/hud/plutus-pioneer-program/code/week07", cradleOptsProg = CradleAction: Cabal}
> Build profile: -w ghc-8.10.2 -O1
> In order, the following will be built (use -v for more details):
>  - plutus-pioneer-program-week07-0.1.0.0 (lib) (first run)
> Preprocessing library for plutus-pioneer-program-week07-0.1.0.0..
2021-05-22 11:12:54.997172 [ThreadId 40] DEBUG hls:	Session loading result: Right (ComponentOptions {componentOptions = ["-fbuilding-cabal-package","-O0","-outputdir","/Users/hud/.cache/hie-bios/dist-week07-5ae59a6283bcfbe664db14e350456567/build/x86_64-osx/ghc-8.10.2/plutus-pioneer-program-week07-0.1.0.0/build","-odir","/Users/hud/.cache/hie-bios/dist-week07-5ae59a6283bcfbe664db14e350456567/build/x86_64-osx/ghc-8.10.2/plutus-pioneer-program-week07-0.1.0.0/build","-hidir","/Users/hud/.cache/hie-bios/dist-week07-5ae59a6283bcfbe664db14e350456567/build/x86_64-osx/ghc-8.10.2/plutus-pioneer-program-week07-0.1.0.0/build","-stubdir","/Users/hud/.cache/hie-bios/dist-week07-5ae59a6283bcfbe664db14e350456567/build/x86_64-osx/ghc-8.10.2/plutus-pioneer-program-week07-0.1.0.0/build","-i","-i/Users/hud/.cache/hie-bios/dist-week07-5ae59a6283bcfbe664db14e350456567/build/x86_64-osx/ghc-8.10.2/plutus-pioneer-program-week07-0.1.0.0/build","-isrc","-i/Users/hud/.cache/hie-bios/dist-week07-5ae59a6283bcfbe664db14e350456567/build/x86_64-osx/ghc-8.10.2/plutus-pioneer-program-week07-0.1.0.0/build/autogen","-i/Users/hud/.cache/hie-bios/dist-week07-5ae59a6283bcfbe664db14e350456567/build/x86_64-osx/ghc-8.10.2/plutus-pioneer-program-week07-0.1.0.0/build/global-autogen","-I/Users/hud/.cache/hie-bios/dist-week07-5ae59a6283bcfbe664db14e350456567/build/x86_64-osx/ghc-8.10.2/plutus-pioneer-program-week07-0.1.0.0/build/autogen","-I/Users/hud/.cache/hie-bios/dist-week07-5ae59a6283bcfbe664db14e350456567/build/x86_64-osx/ghc-8.10.2/plutus-pioneer-program-week07-0.1.0.0/build/global-autogen","-I/Users/hud/.cache/hie-bios/dist-week07-5ae59a6283bcfbe664db14e350456567/build/x86_64-osx/ghc-8.10.2/plutus-pioneer-program-week07-0.1.0.0/build","-optP-include","-optP/Users/hud/.cache/hie-bios/dist-week07-5ae59a6283bcfbe664db14e350456567/build/x86_64-osx/ghc-8.10.2/plutus-pioneer-program-week07-0.1.0.0/build/autogen/cabal_macros.h","-this-unit-id","plutus-pioneer-program-week07-0.1.0.0-inplace","-hide-all-packages","-Wmissing-home-modules","-no-user-package-db","-package-db","/Users/hud/.cabal/store/ghc-8.10.2/package.db","-package-db","/Users/hud/.cache/hie-bios/dist-week07-5ae59a6283bcfbe664db14e350456567/packagedb/ghc-8.10.2","-package-db","/Users/hud/.cache/hie-bios/dist-week07-5ae59a6283bcfbe664db14e350456567/build/x86_64-osx/ghc-8.10.2/plutus-pioneer-program-week07-0.1.0.0/package.conf.inplace","-package-id","sn-1.5.6.0-0fd73a0b","-package-id","base-4.14.1.0","-package-id","containers-0.6.2.1","-package-id","dt-dflt-0.7.1.1-b193147c","-package-id","frr-xtrs-0.1.0.0-27e2fdf0","-package-id","plygrnd-cmmn-0.1.0.0-c041d089","-package-id","plts-cntrct-0.1.0.0-1f35f431","-package-id","plts-ldgr-0.1.0.0-bd122c2d","-package-id","plts-ldgr-p-0.1.0.0-36cb991a","-package-id","plts-tx-0.1.0.0-1ecdc4cc","-package-id","plts-tx-plgn-0.1.0.0-b5ecfd22","-package-id","plts-s-css-0.1.0.0-f8040030","-package-id","prttyprntr-1.7.0-2cde5284","-package-id","text-1.2.3.2","-XHaskell2010","Week07.EvenOdd","Week07.StateMachine","Week07.Test","Week07.TestStateMachine","-Wall","-fobject-code","-fno-ignore-interface-pragmas","-fno-omit-interface-pragmas","-fno-strictness","-fno-spec-constr","-fno-specialise","-hide-all-packages"], componentRoot = "/Users/hud/plutus-pioneer-program/code/week07", componentDependencies = ["plutus-pioneer-program-week07.cabal","cabal.project","cabal.project.local"]},"/Users/hud/.ghcup/ghc/8.10.2/lib/ghc-8.10.2")
2021-05-22 11:12:55.097871 [ThreadId 40] INFO hls:	Using interface files cache dir: /Users/hud/.cache/ghcide/plutus-pioneer-program-week07-0.1.0.0-inplace-2daa66bb72fd943657903e8aadaaddd4f631c26c
2021-05-22 11:12:55.09815 [ThreadId 40] INFO hls:	Making new HscEnv[plutus-pioneer-program-week07-0.1.0.0-inplace]
2021-05-22 11:12:55.125513 [ThreadId 40] DEBUG hls:	New Component Cache HscEnvEq: (([],Just HscEnvEq 5),fromList [("/Users/hud/plutus-pioneer-program/code/week07/hie.yaml",Just 2021-05-20 11:58:19.082247131 UTC),("cabal.project",Just 2021-05-20 11:58:19.082012496 UTC),("cabal.project.local",Nothing),("plutus-pioneer-program-week07.cabal",Just 2021-05-20 11:58:19.082446397 UTC)])
2021-05-22 11:12:55.134256 [ThreadId 40] DEBUG hls:	Known files updated: fromList [(TargetModule Week07.TestStateMachine,fromList ["/Users/hud/plutus-pioneer-program/code/week07/src/Week07/TestStateMachine.hs"]),(TargetModule Week07.StateMachine,fromList ["/Users/hud/plutus-pioneer-program/code/week07/src/Week07/StateMachine.hs"]),(TargetFile NormalizedFilePath "/Users/hud/plutus-pioneer-program/code/week07/src/Week07/Homework.hs",fromList ["/Users/hud/plutus-pioneer-program/code/week07/src/Week07/Homework.hs"]),(TargetModule Week07.Test,fromList ["/Users/hud/plutus-pioneer-program/code/week07/src/Week07/Test.hs"]),(TargetModule Week07.EvenOdd,fromList ["/Users/hud/plutus-pioneer-program/code/week07/src/Week07/EvenOdd.hs"])]
2021-05-22 11:12:55.134633 [ThreadId 40] DEBUG hls:	Restarting build session (aborting the previous one took 0.00s)
2021-05-22 11:12:55.13478 [ThreadId 18] DEBUG hls:	Finishing build session(exception: AsyncCancelled)
2021-05-22 11:12:55.136251 [ThreadId 85] DEBUG hls:	hlint:getIdeas:file:NormalizedFilePath "/Users/hud/plutus-pioneer-program/code/week07/src/Week07/TestStateMachine.hs"
2021-05-22 11:12:55.136291 [ThreadId 79] DEBUG hls:	hlint:getIdeas:file:NormalizedFilePath "/Users/hud/plutus-pioneer-program/code/week07/src/Week07/EvenOdd.hs"
2021-05-22 11:12:55.136326 [ThreadId 83] DEBUG hls:	hlint:getIdeas:file:NormalizedFilePath "/Users/hud/plutus-pioneer-program/code/week07/src/Week07/Test.hs"
2021-05-22 11:12:55.136558 [ThreadId 84] DEBUG hls:	hlint:getIdeas:file:NormalizedFilePath "/Users/hud/plutus-pioneer-program/code/week07/src/Week07/Homework.hs"
2021-05-22 11:12:55.136844 [ThreadId 85] DEBUG hls:	hlint:getIdeas:file:NormalizedFilePath "/Users/hud/plutus-pioneer-program/code/week07/src/Week07/StateMachine.hs"
2021-05-22 11:12:55.145115 [ThreadId 124] INFO hls:	File:     /Users/hud/plutus-pioneer-program/code/week07/src/Week07/Homework.hs
Hidden:   no
Range:    119:5-119:5
Source:   parser
Severity: DsError
Message:  parse error (possibly incorrect indentation or mismatched brackets)
[1]    16509 segmentation fault  ~/.ghcup/bin/haskell-language-server-8.10.2 "--debug"

Please advise.

@isovector
Copy link
Collaborator

@hududed the segmentation fault suggests it's not HLS' fault; it's extremely hard to get Haskell to cause a segfault.

@jneira jneira added status: needs attention and removed status: needs info Not actionable, because there's missing information labels May 25, 2021
@pepeiborra
Copy link
Collaborator

There is a simple workaround as you have found: use Linux. If you are stuck with Mac OS, try building HLS locally using --enable-executable-dynamic, more details in #469

@tdiesler
Copy link
Author

tdiesler commented Jun 18, 2021

I built hls-1.2.0 on MacOS like this ...

./cabal-hls-install --enable-executable-dynamic hls-8.10.4

... and unfortunately got the same error.

@fendor
Copy link
Collaborator

fendor commented Jun 18, 2021

 ./cabal-hls-install --enable-executable-dynamic hls-8.10.4

The installation script doesn't support such arguments. It should work if you invoke cabal configure --enable-executable-dynamic && ./cabal-hls-install hls-8.10.4

@tdiesler
Copy link
Author

Thanks, but same error unfortunately.

@quangIO
Copy link

quangIO commented Jun 19, 2021

The workaround fixes the issue for me. I add the line executable-dynamic: True to ~/.cabal/config, then run

cabal clean # just to be sure
cabal build exe:haskell-language-server-wrapper
cabal install exe:haskell-language-server-wrapper --overwrite-policy=always

@tdiesler
Copy link
Author

Lovely, that works - Merci

@jneira
Copy link
Member

jneira commented Jun 19, 2021

Afaik cabal should honour --enable-executable-dynamic and it shouls have the same effect than change the global config.
I've not found any issue in the cabal project about.

@korayal
Copy link
Contributor

korayal commented Jun 21, 2021

We've been having this same issue on our macOS environment, and I can confirm that --enable-executable-dynamic fixes the problem. I was able to build HLS HEAD on nix with this flag enabled here (FYI, I heavily suggest using the cachix cache mentioned in the repository, otherwise it takes forever to build) for GHC 8.10.4, and I do not get my LSP server terminated any more.

@jneira
Copy link
Member

jneira commented Jun 22, 2021

Afaik cabal should honour --enable-executable-dynamic and it shouls have the same effect than change the global config.
I've not found any issue in the cabal project about.

Maybe the problem is cabal configure --enable-executable-dynamic which writes the option to cabal.project.local. The updated/created cabal.project.local should be the placed in the root of the project and no inside ./install. So if you run the command inside ./install it will not work for hls but for the install program itself.
@tdiesler maybe that was the cause it did not work for you?

@jneira jneira changed the title HLS keeps crashing with plutus pioneer program HLS keeps crashing (exit code -11, segfault, bus error, ..) with plutus pioneer program Jun 22, 2021
@franleplant
Copy link

The workaround fixes the issue for me. I add the line executable-dynamic: True to ~/.cabal/config, then run

cabal clean # just to be sure
cabal build exe:haskell-language-server-wrapper
cabal install exe:haskell-language-server-wrapper --overwrite-policy=always

I got this when trying to use this solution

HEAD is now at a761044 HasContextEntry
cabal: Internal error in target matching. It should always be possible to find
a syntax that's sufficiently qualified to give an unambiguous match. However
when matching 'exe:haskell-language-server-wrapper' we found
exe:haskell-language-server-wrapper (unknown-component) which does not have an
unambiguous syntax. The possible syntax and the targets they match are as
follows:
'exe:haskell-language-server-wrapper' which matches
exe:haskell-language-server-wrapper (unknown-component),
:pkg:exe:lib:exe:file:haskell-language-server-wrapper (unknown-file)

@jneira
Copy link
Member

jneira commented Jan 31, 2022

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!

@jneira jneira closed this as completed Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can-workaround type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

9 participants