NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.16k stars 14.19k forks source link

haskell-language-server hangs on some systems, but not on others #145791

Open KAction opened 3 years ago

KAction commented 3 years ago

Describe the bug

I have several systems, running inside Virtual Box with MacOS host, all of them running Nix. On one of them (Void Linux, linux=5.13.13_1) haskell-language-server works as expected, on two others -- Debian stable (5.10.0-9-amd64) and custom distribution (linux=5.15.2) it hangs with following strace:

write(1, "tep 4/4: Type checking the files"..., 33tep 4/4: Type checking the files
) = 33
futex(0x7f7cf0000bec, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f7cf0000bf0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x6f61478, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x78fe368, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY

I am somewhat stuck how to debug further. Any chance that GHC generates code that makes some assumptions about kernel, given that box that works has the freshest kernel? Or any other ideas.

For what it worth, it also works correctly on host MacOS ( 20.6.0 Darwin Kernel Version 20.6.0).

A clear and concise description of what the bug is.

Steps To Reproduce

Steps to reproduce the behavior:

  1. $ nix-shell -p haskellPackages.haskell-language-server
  2. $ mkdir /tmp/foo && echo 'main = foo' > /tmp/foo/foo.hs
  3. $ cd /tmp/foo && haskell-language-server

Expected behavior

haskell-language-server do not hang at step 4. This is how it looks like at boxes where it works:

haskell-language-server version: 1.2.0.0 (GHC: 8.10.4) (PATH: /nix/store/9gy0sqzk1fnnwkf18rkxmj2lxhbc71ck-haskell-language-server-1.2.0.0/bin/haskell-language-server)
 ghcide setup tester in /private/tmp/foo.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in /private/tmp/foo
Found 1 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
  ()

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
2021-11-13 16:01:10.726568 [ThreadId 54] INFO hls:  Consulting the cradle for "foo.hs"
2021-11-13 16:01:10.727213 [ThreadId 54] WARNING hls:   No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for foo.hs.
 Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie).
You should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error.
Output from setting up the cradle Cradle {cradleRootDir = "/private/tmp/foo", cradleOptsProg = CradleAction: Default}
2021-11-13 16:01:10.884647 [ThreadId 54] INFO hls:  Using interface files cache dir: /Users/dmitrybogatov/.cache/ghcide/main-da39a3ee5e6b4b0d3255bfef95601890afd80709
2021-11-13 16:01:10.884753 [ThreadId 54] INFO hls:  Making new HscEnv[main]
2021-11-13 16:01:10.905613 [ThreadId 149] INFO hls: File:     /private/tmp/foo/foo.hs
Hidden:   no
Range:    1:8-1:11
Source:   typecheck
Severity: DsError
Message:  Variable not in scope: foo
2021-11-13 16:01:10.905868 [ThreadId 152] INFO hls: finish: User TypeCheck (took 0.02s)
2021-11-13 16:01:10.907873 [ThreadId 161] INFO hls: finish: GetHie (took 0.00s)

Completed (1 file worked, 0 files failed)
2021-11-13 16:01:10.907995 [ThreadId 162] INFO hls: finish: GenerateCore (took 0.00s)

and this is how it looks like at boxes where it does not work:

[nix-shell:/tmp/foo]$ haskell-language-server
haskell-language-server version: 1.4.0.0 (GHC: 8.10.7) (PATH: /nix/store/db38326gk5cjip9x0qqsd8k639pnmqli-haskell-language-server-1.4.0.0/bin/haskell-language-server)
 ghcide setup tester in /tmp/foo.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in /tmp/foo
Found 1 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
  ()

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files

Metadata

This is output of nix-shell -p nix-info --run "nix-info -m" on problematic Debian box.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.0-9-amd64, Debian GNU/Linux, 11 (bullseye)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.4`
 - channels(root): `"nixpkgs-21.11pre330378.36941818f25"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`

Maintainer information:

attribute:
  - haskellPackages.haskell-language-server
KAction commented 3 years ago

For what it worth, just upgraded Debian box to Sid (debian 5.14.0-4-amd64), and it still does not work.

sternenseemann commented 2 years ago

cc @maralorn

maralorn commented 2 years ago

I am honestly no expert in regard to OS details. In general I think hls shouldn‘t hang, no matter how weird the environment it’s in. So this is probably a bug worth reporting upstream? Have you tried to install hls via other means (e.g. ghcup) and witnessed a different behavior? One possible problem I can think of would be if you have a ghc or cabal from the host system in your environment. That could cause trouble. (But still, it shouldn‘t hang.)

KAction commented 2 years ago

I tried building using stack(1), but it complains that no binary distribution found for my (libc, curses) version. I tried to rebuild on my hls on my box from Nix sources (substitute = false) with no avail.

ParetoOptimalDev commented 2 years ago

I tried building using stack(1), but it complains that no binary distribution found for my (libc, curses) version. I tried to rebuild on my hls on my box from Nix sources (substitute = false) with no avail.

Have you tried with just cabal? Also you might have ABI issues, this script might help you determine if so:

https://github.com/NixOS/nixpkgs/issues/175565