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

assertion failure from hls and ghc 8.10: `freesize < size' failed #429

Closed
peterwicksstringfield opened this issue Sep 24, 2020 · 18 comments
Labels
can-workaround type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@peterwicksstringfield
Copy link
Contributor

peterwicksstringfield commented Sep 24, 2020

Subject of the issue

When I try to use haskell language server 0.4.0 on my project, which uses GHC 8.10.2 and a typechecker plugin, I get an error message:

haskell-language-server-8.10.2: allocatestack.c:384: advise_stack_range: Assertion `freesize < size' failed.
haskell-language-server-wrapper: callProcess: /home/builder/.ghcup/bin/haskell-language-server-8.10.2 (exit -6): failed

and the language server does not load.

Here is a simple test-project, consisting of a cabal file, an hie.yaml, and two source files, one of which defines a (stubbed out) typechecker plugin, and the other of which invokes the plugin. The -fobject-code flag is set in the cabal file.

src/SomePlugin.hs:

module SomePlugin (plugin) where

import Plugins
  ( Plugin (..),
    defaultPlugin,
  )
import TcRnTypes
  ( TcPlugin (..),
    TcPluginResult (..),
  )

plugin :: Plugin
plugin =
  defaultPlugin
    { tcPlugin =
        const $
          Just $
            TcPlugin
              { tcPluginInit = return (),
                tcPluginSolve = \_ _ _ _ -> return $ TcPluginOk [] [],
                tcPluginStop = \_ -> return ()
              }
    }

app/Main.hs:

{-# OPTIONS_GHC -fplugin SomePlugin #-}

module Main where

main :: IO ()
main = putStrLn "Hello, Haskell!"

https://github.com/peterwicksstringfield/hls-assertion-failure-example

If you have git and docker, you should be able to replicate the error like this:

git clone https://github.com/peterwicksstringfield/hls-assertion-failure-example
cd hls-assertion-failure-example
docker build -t testbuild .
docker run -it --rm testbuild
[inside container] haskell-language-server-wrapper

If you don't have docker, but you do have git, ghc-8.10.2, and cabal, then this should work too:

git clone https://github.com/peterwicksstringfield/hls-assertion-failure-example
cd hls-assertion-failure-example
cabal v2-install --lib ghc
cabal v2-build
haskell-language-server-wrapper

Maybe I'm doing something wrong, but even if I am, I don't think I should be seeing raw assertion failures?

When i delete the "{-# OPTIONS_GHC -fplugin SomePlugin #-}" line, there are no errors and hls is able to load.

Also, the code itself works fine. Inside the container:

builder@6d755dfa0de8:~/project$ cabal v2-install --lib .
Wrote tarball sdist to
/home/builder/project/dist-newstyle/sdist/component-0.0.0.tar.gz
Resolving dependencies...
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details):
 - component-0.0.0 (lib) (requires build)
Starting     component-0.0.0 (lib)
Building     component-0.0.0 (lib)
Installing   component-0.0.0 (lib)
Completed    component-0.0.0 (lib)
builder@6d755dfa0de8:~/project$ ghci app/Main.hs 
GHCi, version 8.10.2: https://www.haskell.org/ghc/  :? for help
Loaded package environment from /home/builder/.ghc/x86_64-linux-8.10.2/environments/default
[1 of 1] Compiling Main             ( app/Main.hs, interpreted )
Ok, one module loaded.
*Main> main 
Hello, Haskell!

Your environment

Inside the container:

builder@ec3ae181a237:~/project$ haskell-language-server-wrapper --probe-tools
haskell-language-server version: 0.4.0.0 (GHC: 8.10.1) (PATH: /home/builder/.ghcup/bin/haskell-language-server-wrapper-0.4.0) (GIT hash: 0a18edde24923251a148cbbc0ae993a6aac83b9c)
Tool versions found on the $PATH
cabal:		3.2.0.0
stack:		Not found
ghc:		8.10.2

The lsp-client is irrelevant, but I use emacs.

component.cabal:

cabal-version: 1.12

name:           component
version:        0.0.0
build-type:     Simple

library
  exposed-modules:
      SomePlugin
  hs-source-dirs:
      src/
  build-depends:
      base
    , ghc
  default-language: Haskell2010

executable component
  main-is: Main.hs
  hs-source-dirs:
      app/
  ghc-options: -fobject-code
  build-depends:
      base
    , component
    , ghc
  default-language: Haskell2010

No stack.yaml or package.yaml. Cabal only.

hie.yaml:

cradle:
  cabal:
    - path: "src/"
      component: "lib:component"

    - path: "app/Main.hs"
      component: "component:exe:component"

Include debug information

I deleted the details tags because they seemed to be breaking the formatting for the code tags. (???).

Inside the container:
builder@6ce4adabd820:~/project$ haskell-language-server-wrapper --debug
Found "/home/builder/project/hie.yaml" for "/home/builder/project/a"
Module "/home/builder/project/a" is loaded by Cradle: Cradle {cradleRootDir = "/home/builder/project", cradleOptsProg = CradleAction: Cabal}
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 0.4.0.0, Git revision 0a18edde24923251a148cbbc0ae993a6aac83b9c (dirty) x86_64 ghc-8.10.1
Current directory: /home/builder/project
Operating system: linux
Arguments: ["--debug"]
Cradle directory: /home/builder/project
Cradle type: Cabal

Tool versions found on the $PATH
cabal:		3.2.0.0
stack:		Not found
ghc:		8.10.2


Consulting the cradle to get project GHC version...
Project GHC version: 8.10.2
haskell-language-server exe candidates: ["haskell-language-server-8.10.2","haskell-language-server-8.10","haskell-language-server"]
Launching haskell-language-server exe at:/home/builder/.ghcup/bin/haskell-language-server-8.10.2
haskell-language-server version: 0.4.0.0 (GHC: 8.10.2) (PATH: /home/builder/.ghcup/bin/haskell-language-server-8.10.2~0.4.0) (GIT hash: 0a18edde24923251a148cbbc0ae993a6aac83b9c)
(haskell-language-server)Ghcide setup tester in /home/builder/project.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Tool versions found on the $PATH
cabal:		3.2.0.0
stack:		Not found
ghc:		8.10.2


Step 1/4: Finding files to test in /home/builder/project
Found 2 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
[INFO] Consulting the cradle for "/home/builder/project/src/SomePlugin.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/builder/project", cradleOptsProg = CradleAction: Cabal}
> Resolving dependencies...
> Build profile: -w ghc-8.10.2 -O1
> In order, the following will be built (use -v for more details):
>  - component-0.0.0 (lib) (configuration changed)
> Configuring library for component-0.0.0..
> Preprocessing library for component-0.0.0..
[INFO] Using interface files cache dir: /home/builder/.cache/ghcide/component-0.0.0-inplace-e9adde0a53c6823865dc33c77fb9bc4bc81784ce
[INFO] Making new HscEnv[component-0.0.0-inplace]
[INFO] Consulting the cradle for "/home/builder/project/app/Main.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/builder/project", cradleOptsProg = CradleAction: Cabal}
> Resolving dependencies...
> Build profile: -w ghc-8.10.2 -O1
> In order, the following will be built (use -v for more details):
>  - component-0.0.0 (lib) (configuration changed)
>  - component-0.0.0 (exe:component) (configuration changed)
> Configuring library for component-0.0.0..
> Preprocessing library for component-0.0.0..
> Building library for component-0.0.0..
> Configuring executable 'component' for component-0.0.0..
> Warning: The package has an extraneous version range for a dependency on an
> internal library: component -any && ==0.0.0. This version range includes the
> current package but isn't needed as the current package's library will always
> be used.
> Preprocessing executable 'component' for component-0.0.0..
[INFO] Using interface files cache dir: /home/builder/.cache/ghcide/main-c7b080054f831268daf0eb498153e1c44cee84cb
[INFO] Using interface files cache dir: /home/builder/.cache/ghcide/component-0.0.0-inplace-1362c3eaf35ec9e6bff2323ec5cf5d3719d8afa5
[INFO] Making new HscEnv[main,component-0.0.0-inplace]

Completed (2 files worked, 0 files failed)
[INFO] finish: User TypeCheck (took 0.59s)
haskell-language-server-8.10.2: allocatestack.c:384: advise_stack_range: Assertion `freesize < size' failed.
haskell-language-server-wrapper: callProcess: /home/builder/.ghcup/bin/haskell-language-server-8.10.2 "--debug" (exit -6): failed
@Ailrun Ailrun added status: needs repro type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Sep 24, 2020
@jneira
Copy link
Member

jneira commented Sep 24, 2020

Hi, i cant reproduce in windows and ghc-8.10.1, following the git+cabal steps.
My log has been:

PS D:\dev\ws\haskell\issues\hls-assertion-failure-example> haskell-language-server-wrapper
Found "D:\dev\ws\haskell\issues\hls-assertion-failure-example\hie.yaml" for "D:\dev\ws\haskell\issues\hls-assertion-failure-example\a"
Module "D:\dev\ws\haskell\issues\hls-assertion-failure-example\a" is loaded by Cradle: Cradle {cradleRootDir = "D:\\dev\\ws\\haskell\\issues\\hls-assertion-failure-example", cradleOptsProg = CradleAction: Cabal}
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper.exe) Version 0.4.0.0 x86_64 ghc-8.10.1
Current directory: D:\dev\ws\haskell\issues\hls-assertion-failure-example
Operating system: mingw32
Arguments: []
Cradle directory: D:\dev\ws\haskell\issues\hls-assertion-failure-example
Cradle type: Cabal

Tool versions found on the $PATH
cabal:          3.2.0.0
stack:          2.3.3
ghc:            8.10.1


Consulting the cradle to get project GHC version...
Project GHC version: 8.10.1
haskell-language-server exe candidates: ["haskell-language-server-8.10.1.exe","haskell-language-server-8.10.exe","haskell-language-server.exe"]
Launching haskell-language-server exe at:D:\bin\haskell-language-server-8.10.1.exe
haskell-language-server version: 0.4.0.0 (GHC: 8.10.1) (PATH: D:\bin\haskell-language-server-8.10.1.exe)
(haskell-language-server)Ghcide setup tester in D:\dev\ws\haskell\issues\hls-assertion-failure-example.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Tool versions found on the $PATH
cabal:          3.2.0.0
stack:          2.3.3
ghc:            8.10.1


Step 1/4: Finding files to test in D:\dev\ws\haskell\issues\hls-assertion-failure-example
Found 2 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
Output from setting up the cradle Cradle {cradleRootDir = "D:\\dev\\ws\\haskell\\issues\\hls-assertion-failure-example", cradleOptsProg = CradleAction: Cabal}
> Resolving dependencies...
> Build profile: -w ghc-8.10.1 -O1
> In order, the following will be built (use -v for more details):
>  - component-0.0.0 (lib) (configuration changed)
>  - component-0.0.0 (exe:component) (configuration changed)
> Configuring library for component-0.0.0..
> Preprocessing library for component-0.0.0..
> Building library for component-0.0.0..
> Configuring executable 'component' for component-0.0.0..
> Warning: The package has an extraneous version range for a dependency on an
> internal library: component -any && ==0.0.0. This version range includes the
> current package but isn't needed as the current package's library will always
> be used.
> Preprocessing executable 'component' for component-0.0.0..
[INFO] Using interface files cache dir: C:\Users\atrey\AppData\Local\ghcide\main-9a59fc60f074a96993018bb5dac58e7286a735e9
[INFO] Making new HscEnv[main]
[INFO] Consulting the cradle for "src\\SomePlugin.hs"
Output from setting up the cradle Cradle {cradleRootDir = "D:\\dev\\ws\\haskell\\issues\\hls-assertion-failure-example", cradleOptsProg = CradleAction: Cabal}
> Resolving dependencies...
> Build profile: -w ghc-8.10.1 -O1
> In order, the following will be built (use -v for more details):
>  - component-0.0.0 (lib) (ephemeral targets)
> Preprocessing library for component-0.0.0..
[INFO] Using interface files cache dir: C:\Users\atrey\AppData\Local\ghcide\component-0.0.0-inplace-accaa76471ea57a8879e5a21120801b93d33bde1
[INFO] Using interface files cache dir: C:\Users\atrey\AppData\Local\ghcide\main-79537733544b9e3a90805e863338cf03924915c4
[INFO] Making new HscEnv[component-0.0.0-inplace,main]

Completed (2 files worked, 0 files failed)
PS D:\dev\ws\haskell\issues\hls-assertion-failure-example>

But i dont get [INFO] finish: User TypeCheck (took 0.59s) neither, maybe some step is missing?

@peterwicksstringfield
Copy link
Contributor Author

I can reproduce this from a fresh copy of the example by copy and pasting the git steps I gave above. Probably something different about my system. I'm running Ubuntu, and the docker container is based on Debian, so its pretty similar to my real environment and quite different than your Windows one.

If you delete the "{-# OPTIONS_GHC -fplugin SomePlugin #-}" from app/Main.hs, and try "haskell-language-server-wrapper" again, does the "[INFO] finish: User TypeCheck (took 0.59s)" show up?

Sorry, I was hoping this would be easier to reproduce. If it doesn't show up for other people it might not be worth your time to investigate.

@jneira
Copy link
Member

jneira commented Sep 25, 2020

No worries, others can try it in linux or macos to confirm it.

If you delete the "{-# OPTIONS_GHC -fplugin SomePlugin #-}" from app/Main.hs, and try "haskell-language-server-wrapper" again, does the "[INFO] finish: User TypeCheck (took 0.59s)" show up?

Nop, i got the same output as without it (last line is Completed (2 files worked, 0 files failed))

@tomsmeding
Copy link

tomsmeding commented Nov 8, 2020

For what it's worth, if I run the docker container in the original issue on my system (Arch Linux), it downloads HLS 0.5.1; I do get the finish: User TypeCheck line, but the docker build doesn't even succeed because the final haskell-language-server-wrapper invocation in the Dockerfile crashes with the familiar assertion error.

I ran into this issue on a larger project; on https://github.com/AccelerateHS/accelerate, branch master (currently commit d502dda341442a01c71205b74ae07df5d756f001), I get the same assertion error. As far as I know, there are no GHC plugins involved here. (But of course the project is quite large, sorry for that.)

@codygman
Copy link

codygman commented Dec 3, 2020

I just got this issue on my work codebase:

haskell-language-server_1    | haskell-language-server version: 0.6.0.0 (GHC: 8.10.2) (PATH: /haskell-language-server/haskell-language-server-Linux-8.10.2) (GIT hash: 372a12e797069dc3ac4fa33dcaabe3b992999d7c)
...
haskell-language-server_1    | haskell-language-server-Linux-8.10.2: allocatestack.c:384: advise_stack_range: Assertion `freesize < size' failed.

@amesgen
Copy link
Contributor

amesgen commented Jan 6, 2021

I have a minimal reproducible example (without any GHC plugins, only TemplateHaskell) for this bug here.

Run

git clone --single-branch --branch hls-allocatestack-bug https://github.com/amesgen/stuff.git && cd stuff

and then run the pre-built binaries for 0.8.0 (I use GHC 8.10.3)

 $ haskell-language-server-wrapper
(usual output, everything successful)
haskell-language-server-8.10.3: allocatestack.c:384: advise_stack_range: Assertion `freesize < size' failed.
haskell-language-server-wrapper: callProcess: /home/alexander/.local/bin/haskell-language-server-8.10.3 (exit -6): failed

If I build 0.8.0 from source locally, everything works fine:

 $ export PATH=~/.cabal/bin:$PATH
 $ haskell-language-server-wrapper
(usual output, everything successful, as above, but without the assertion failure)

tool probe (prebuilt binaries)
haskell-language-server version: 0.8.0.0 (GHC: 8.10.1) (PATH: /home/alexander/.local/bin/haskell-language-server-wrapper-0.8.0) (GIT hash: eb58f13f7b8e4f9bc771af30ff9fd82dc4309ff5)
Tool versions found on the $PATH
cabal:		3.4.0.0
stack:		2.5.1
ghc:		8.10.3
tool probe (built from source)
haskell-language-server version: 0.8.0.0 (GHC: 8.10.3) (PATH: /home/alexander/.cabal/store/ghc-8.10.3/haskell-language-server-0.8.0.0-e-haskell-language-server-wrapper-68081f03af45252e0b8cb11bf5c40aadbeb5fa0c25845b76a8e868a3066de983/bin/haskell-language-server-wrapper)
Tool versions found on the $PATH
cabal:		3.4.0.0
stack:		2.5.1
ghc:		8.10.3

@peterwicksstringfield
Copy link
Contributor Author

peterwicksstringfield commented Jan 10, 2021

amesgen's example works for me too. Assertion failure with haskell-language-server-8.10.3, 0.8.0 from ghcup, no failure with a local build of 0.8.0.

It's the same with my own project (on ghc 8.10.2), the one that prompted me to open this ticket in the first place. The released haskell-language-8.10.2, 0.8.0 from ghcup has the assertion failure, and a local build does not.

My local builds were created off the 0.8.0 tag:

peter@gtower:~/haskell-language-server$ git show
commit eb58f13f7b8e4f9bc771af30ff9fd82dc4309ff5 (HEAD, tag: hls-plugin-api-0.6.0.0, tag: ghcide-0.7.0.0, tag: 0.8.0)

That assertion failure is coming from glibc afaict.

Here are my logs from trying amesgen's example.

Release build (assertion failure):
peter@gtower:~/stuff$ haskell-language-server-8.10.3
haskell-language-server version: 0.8.0.0 (GHC: 8.10.3) (PATH: /home/peter/.ghcup/bin/haskell-language-server-8.10.3~0.8.0) (GIT hash: eb58f13f7b8e4f9bc771af30ff9fd82dc4309ff5)
(haskell-language-server)Ghcide setup tester in /home/peter/stuff.
Report bugs at https://github.com/haskell/haskell-language-server/issues

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

Step 1/4: Finding files to test in /home/peter/stuff
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
[INFO] Consulting the cradle for "src/Lib.hs"
NotShowMessage (NotificationMessage {_jsonrpc = "2.0", _method = WindowShowMessage, _params = ShowMessageParams {_xtype = MtInfo, _message = "No cradle found for src/Lib.hs.\n Proceeding with implicit cradle.\nYou should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error."}})
Output from setting up the cradle Cradle {cradleRootDir = "/home/peter/stuff", cradleOptsProg = CradleAction: Cabal}

Warning: Requested index-state2020-01-06T00:00:00Z is newer than
'hackage.haskell.org'! Falling back to older state (2020-01-05T23:51:23Z).
Resolving dependencies...
Build profile: -w ghc-8.10.3 -O1
In order, the following will be built (use -v for more details):

  • hls-allocatestack-bug-0.1.0.0 (lib) (configuration changed)
    Configuring library for hls-allocatestack-bug-0.1.0.0..
    Preprocessing library for hls-allocatestack-bug-0.1.0.0..
    [INFO] Using interface files cache dir: ghcide
    [INFO] Making new HscEnv[hls-allocatestack-bug-0.1.0.0-inplace]

Completed (1 file worked, 0 files failed)
haskell-language-server-8.10.3: allocatestack.c:384: advise_stack_range: Assertion `freesize < size' failed.
Aborted (core dumped)

Local build (works):
peter@gtower:~/stuff$ /home/peter/haskell-language-server/.stack-work/install/x86_64-linux-tinfo6/e4e793ae54282cfab5fadd3dd590c27a6b9923a017fc9eee82e8fdc0fd390547/8.10.3/bin/haskell-language-server
haskell-language-server version: 0.8.0.0 (GHC: 8.10.3) (PATH: /home/peter/haskell-language-server/.stack-work/install/x86_64-linux-tinfo6/e4e793ae54282cfab5fadd3dd590c27a6b9923a017fc9eee82e8fdc0fd390547/8.10.3/bin/haskell-language-server) (GIT hash: eb58f13f7b8e4f9bc771af30ff9fd82dc4309ff5)
(haskell-language-server)Ghcide setup tester in /home/peter/stuff.
Report bugs at https://github.com/haskell/haskell-language-server/issues

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

Step 1/4: Finding files to test in /home/peter/stuff
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
[INFO] Consulting the cradle for "src/Lib.hs"
NotShowMessage (NotificationMessage {_jsonrpc = "2.0", _method = WindowShowMessage, _params = ShowMessageParams {_xtype = MtInfo, _message = "No cradle found for src/Lib.hs.\n Proceeding with implicit cradle.\nYou should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error."}})
Output from setting up the cradle Cradle {cradleRootDir = "/home/peter/stuff", cradleOptsProg = CradleAction: Cabal}

Warning: Requested index-state2020-01-06T00:00:00Z is newer than
'hackage.haskell.org'! Falling back to older state (2020-01-05T23:51:23Z).
Resolving dependencies...
Build profile: -w ghc-8.10.3 -O1
In order, the following will be built (use -v for more details):

  • hls-allocatestack-bug-0.1.0.0 (lib) (configuration changed)
    Configuring library for hls-allocatestack-bug-0.1.0.0..
    Preprocessing library for hls-allocatestack-bug-0.1.0.0..
    [INFO] Using interface files cache dir: ghcide
    [INFO] Making new HscEnv[hls-allocatestack-bug-0.1.0.0-inplace]
    [INFO] finish: User TypeCheck (took 0.25s)

Completed (1 file worked, 0 files failed)

Incidentally: the way you make these nice foldable detail sections is like this: "(details) (summary) blah blah (/summary) (pre) blah blah (/pre) (/details)", except with angle brackets not parenthesis. It's html not markdown I think. Maybe that's obvious to other people but it took me a few tries.

@amesgen
Copy link
Contributor

amesgen commented Jan 11, 2021

Maybe statically linking glibc (which is not really well supported: src) is the issue.

Also, there are linker warnings (src):

/home/runner/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/process-1.6.9.0/libHSprocess-1.6.9.0.a(runProcess.o):runProcess.c:function runInteractiveProcess: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/runner/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/process-1.6.9.0/libHSprocess-1.6.9.0.a(runProcess.o):runProcess.c:function runInteractiveProcess: warning: Using 'initgroups' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/runner/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/unix-2.7.2.2/libHSunix-2.7.2.2.a(User.o):ghc_2.c:function ghczuwrapperZC0ZCunixzm2zi7zi2zi2ZCSystemziPosixziUserZCendpwent: warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/runner/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/unix-2.7.2.2/libHSunix-2.7.2.2.a(User.o):ghc_2.c:function ghczuwrapperZC1ZCunixzm2zi7zi2zi2ZCSystemziPosixziUserZCsetpwent: warning: Using 'setpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/runner/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/unix-2.7.2.2/libHSunix-2.7.2.2.a(User.o):ghc_2.c:function ghczuwrapperZC2ZCunixzm2zi7zi2zi2ZCSystemziPosixziUserZCgetpwent: warning: Using 'getpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/runner/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/unix-2.7.2.2/libHSunix-2.7.2.2.a(User.o):ghc_2.c:function ghczuwrapperZC3ZCunixzm2zi7zi2zi2ZCSystemziPosixziUserZCgetpwnamzur: warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/runner/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/unix-2.7.2.2/libHSunix-2.7.2.2.a(User.o):ghc_2.c:function ghczuwrapperZC4ZCunixzm2zi7zi2zi2ZCSystemziPosixziUserZCgetpwuidzur: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/runner/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/unix-2.7.2.2/libHSunix-2.7.2.2.a(User.o):ghc_2.c:function ghczuwrapperZC5ZCunixzm2zi7zi2zi2ZCSystemziPosixziUserZCgetgrnamzur: warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/runner/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/unix-2.7.2.2/libHSunix-2.7.2.2.a(User.o):ghc_2.c:function ghczuwrapperZC6ZCunixzm2zi7zi2zi2ZCSystemziPosixziUserZCgetgrgidzur: warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

rts/Linker.c:597:0: error:
     warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

I built haskell-language-server 0.8.0 ghc 8.10.3 with musl here, but it fails with

Error dynamically loading libm.so.6:
Dynamic loading not supported
File:     /tmp/tmp.Rh5xWmJ1eg/stuff/src/Lib.hs
Hidden:   no
Range:    1:1-2:1
Source:   typecheck
Severity: DsError
Message:  Unexpected usage errorDynamic loading not supported

due to 39ce701, but it also happens if I disable it (use this build), as it is probably also loaded later either way.

@tomsmeding
Copy link

tomsmeding commented Jan 11, 2021

I didn't try the reproducing examples above, but for me a local build of HLS (current master, 16aee6e, ghc 8.8.4) works on https://github.com/AccelerateHS/accelerate whereas the version from ghcup does not, with the familiar allocatestack error.

Sorry for spamming; perhaps if more people try the "local build" workaround and it works for them, upvote this message.

@peterwicksstringfield
Copy link
Contributor Author

Yeah I can confirm that part too. Building locally produces a good binary, but building locally with --enable-executable-static produces a binary that segfaults.

build
peter@gtower:~/haskell-language-server$ cabal build exe:haskell-language-server --enable-executable-static
Build profile: -w ghc-8.10.3 -O1
In order, the following will be built (use -v for more details):
 - hie-compat-0.1.0.0 (lib) (configuration changed)
 - hls-plugin-api-0.6.0.0 (lib) (configuration changed)
 - ghcide-0.7.0.0 (lib) (configuration changed)
 - hls-tactics-plugin-0.5.1.0 (lib) (configuration changed)
 - hls-retrie-plugin-0.1.0.0 (lib) (configuration changed)
 - hls-hlint-plugin-0.1.0.0 (lib) (configuration changed)
 - hls-explicit-imports-plugin-0.1.0.0 (lib) (configuration changed)
 - hls-eval-plugin-0.1.0.0 (lib) (configuration changed)
 - hls-class-plugin-0.1.0.0 (lib) (configuration changed)
 - haskell-language-server-0.8.0.0 (lib) (configuration changed)
 - haskell-language-server-0.8.0.0 (exe:haskell-language-server) (configuration changed)
Configuring library for hie-compat-0.1.0.0..
Configuring library for hls-plugin-api-0.6.0.0..
Preprocessing library for hie-compat-0.1.0.0..
Building library for hie-compat-0.1.0.0..
Preprocessing library for hls-plugin-api-0.6.0.0..
Building library for hls-plugin-api-0.6.0.0..
Configuring library for ghcide-0.7.0.0..
Preprocessing library for ghcide-0.7.0.0..
Building library for ghcide-0.7.0.0..
Configuring library for hls-tactics-plugin-0.5.1.0..
Configuring library for hls-hlint-plugin-0.1.0.0..
Configuring library for hls-retrie-plugin-0.1.0.0..
Configuring library for hls-explicit-imports-plugin-0.1.0.0..
Preprocessing library for hls-hlint-plugin-0.1.0.0..
Building library for hls-hlint-plugin-0.1.0.0..
Preprocessing library for hls-explicit-imports-plugin-0.1.0.0..
Building library for hls-explicit-imports-plugin-0.1.0.0..
Preprocessing library for hls-retrie-plugin-0.1.0.0..
Building library for hls-retrie-plugin-0.1.0.0..
Preprocessing library for hls-tactics-plugin-0.5.1.0..
Building library for hls-tactics-plugin-0.5.1.0..
Configuring library for hls-eval-plugin-0.1.0.0..
Configuring library for hls-class-plugin-0.1.0.0..
Configuring library for haskell-language-server-0.8.0.0..
Preprocessing library for hls-eval-plugin-0.1.0.0..
Building library for hls-eval-plugin-0.1.0.0..
Preprocessing library for hls-class-plugin-0.1.0.0..
Building library for hls-class-plugin-0.1.0.0..
Preprocessing library for haskell-language-server-0.8.0.0..
Building library for haskell-language-server-0.8.0.0..
Configuring executable 'haskell-language-server' for haskell-language-server-0.8.0.0..
Warning: The package has an extraneous version range for a dependency on an
internal library: haskell-language-server -any && ==0.8.0.0,
haskell-language-server -any && ==0.8.0.0. This version range includes the
current package but isn't needed as the current package's library will always
be used.
Preprocessing executable 'haskell-language-server' for haskell-language-server-0.8.0.0..
Building executable 'haskell-language-server' for haskell-language-server-0.8.0.0..
Linking /home/peter/haskell-language-server/dist-newstyle/build/x86_64-linux/ghc-8.10.3/haskell-language-server-0.8.0.0/x/haskell-language-server/build/haskell-language-server/haskell-language-server ...
/home/peter/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/process-1.6.9.0/libHSprocess-1.6.9.0.a(runProcess.o):runProcess.c:function runInteractiveProcess: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/peter/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/process-1.6.9.0/libHSprocess-1.6.9.0.a(runProcess.o):runProcess.c:function runInteractiveProcess: warning: Using 'initgroups' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/peter/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/unix-2.7.2.2/libHSunix-2.7.2.2.a(User.o):ghc_2.c:function ghczuwrapperZC0ZCunixzm2zi7zi2zi2ZCSystemziPosixziUserZCendpwent: warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/peter/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/unix-2.7.2.2/libHSunix-2.7.2.2.a(User.o):ghc_2.c:function ghczuwrapperZC1ZCunixzm2zi7zi2zi2ZCSystemziPosixziUserZCsetpwent: warning: Using 'setpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/peter/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/unix-2.7.2.2/libHSunix-2.7.2.2.a(User.o):ghc_2.c:function ghczuwrapperZC2ZCunixzm2zi7zi2zi2ZCSystemziPosixziUserZCgetpwent: warning: Using 'getpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/peter/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/unix-2.7.2.2/libHSunix-2.7.2.2.a(User.o):ghc_2.c:function ghczuwrapperZC3ZCunixzm2zi7zi2zi2ZCSystemziPosixziUserZCgetpwnamzur: warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/peter/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/unix-2.7.2.2/libHSunix-2.7.2.2.a(User.o):ghc_2.c:function ghczuwrapperZC4ZCunixzm2zi7zi2zi2ZCSystemziPosixziUserZCgetpwuidzur: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/peter/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/unix-2.7.2.2/libHSunix-2.7.2.2.a(User.o):ghc_2.c:function ghczuwrapperZC5ZCunixzm2zi7zi2zi2ZCSystemziPosixziUserZCgetgrnamzur: warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/peter/.ghcup/ghc/8.10.3/lib/ghc-8.10.3/unix-2.7.2.2/libHSunix-2.7.2.2.a(User.o):ghc_2.c:function ghczuwrapperZC6ZCunixzm2zi7zi2zi2ZCSystemziPosixziUserZCgetgrgidzur: warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

rts/Linker.c:597:0: error:
warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

log
peter@gtower:~/stuff$ /home/peter/haskell-language-server/dist-newstyle/build/x86_64-linux/ghc-8.10.3/haskell-language-server-0.8.0.0/x/haskell-language-server/build/haskell-language-server/haskell-language-server
haskell-language-server version: 0.8.0.0 (GHC: 8.10.3) (PATH: /home/peter/haskell-language-server/dist-newstyle/build/x86_64-linux/ghc-8.10.3/haskell-language-server-0.8.0.0/x/haskell-language-server/build/haskell-language-server/haskell-language-server) (GIT hash: eb58f13f7b8e4f9bc771af30ff9fd82dc4309ff5)
(haskell-language-server)Ghcide setup tester in /home/peter/stuff.
Report bugs at https://github.com/haskell/haskell-language-server/issues

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

Step 1/4: Finding files to test in /home/peter/stuff
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
[INFO] Consulting the cradle for "src/Lib.hs"
NotShowMessage (NotificationMessage {_jsonrpc = "2.0", _method = WindowShowMessage, _params = ShowMessageParams {_xtype = MtInfo, _message = "No cradle found for src/Lib.hs.\n Proceeding with implicit cradle.\nYou should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error."}})
Output from setting up the cradle Cradle {cradleRootDir = "/home/peter/stuff", cradleOptsProg = CradleAction: Cabal}

Warning: Requested index-state2020-01-06T00:00:00Z is newer than
'hackage.haskell.org'! Falling back to older state (2020-01-05T23:51:23Z).
Resolving dependencies...
Build profile: -w ghc-8.10.3 -O1
In order, the following will be built (use -v for more details):

  • hls-allocatestack-bug-0.1.0.0 (lib) (configuration changed)
    Configuring library for hls-allocatestack-bug-0.1.0.0..
    Preprocessing library for hls-allocatestack-bug-0.1.0.0..
    [INFO] Using interface files cache dir: ghcide
    [INFO] Making new HscEnv[hls-allocatestack-bug-0.1.0.0-inplace]

Completed (1 file worked, 0 files failed)
[INFO] finish: User TypeCheck (took 0.22s)
haskell-language-server: allocatestack.c:389: advise_stack_range: Assertion `freesize < size' failed.
Aborted (core dumped)

@dreamsmasher
Copy link

Getting the same error when opening the clash-compiler codebase. haskell-language-server-8.10.3 emits an allocatestack.c:384... Assertion \freesize < size` failed.`

I'm also getting GHC panics, although I'm not sure if that's related to the HLS issue.

@jneira
Copy link
Member

jneira commented Jan 17, 2021

afaiu building from source seems to workaround the issue, correct me if that is not the case

@jneira jneira changed the title assertion failure from hls 0.4.0, ghc 8.10.2, typechecker plugin involved assertion failure from hls and ghc 8.10 Jan 17, 2021
@jneira jneira changed the title assertion failure from hls and ghc 8.10 assertion failure from hls and ghc 8.10: `freesize < size' failed Jan 17, 2021
@dreamsmasher
Copy link

@jneira Yes, it works just fine after building from source, thanks everyone. This is probably worth opening an issue on the ghcup repo too.

@amesgen
Copy link
Contributor

amesgen commented Jan 17, 2021

@dreamsmasher ghcup just uses the pre-built static binaries from the releases page, see here.

Also to reiterate what @peterwicksstringfield said: Locally building only fixes the issue if one does not use --enable-executable-static.

@peterwicksstringfield
Copy link
Contributor Author

Not very helpful ...

gdb traceback
...
[INFO] finish: User TypeCheck (took 0.55s)

Completed (1 file worked, 0 files failed)
hls_8103_debug: allocatestack.c:389: advise_stack_range: Assertion `freesize < size' failed.
...
Thread 5 "hls_8103_debu:w" received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff5e85700 (LWP 293929)]
raise (sig=) at ../sysdeps/unix/sysv/linux/raise.c:50
50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 raise (sig=) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x0000000000400b71 in abort ()
#2 0x0000000000400a41 in __assert_fail_base.cold ()
#3 0x00000000071de446 in __assert_fail ()
#4 0x00000000071a6022 in advise_stack_range (guardsize=, pd=140737319032576, size=, mem=0x7ffff5685000) at allocatestack.c:389
#5 start_thread (arg=) at pthread_create.c:567
#6 0x0000000007267de3 in clone ()

@jneira
Copy link
Member

jneira commented Mar 30, 2021

The error has emerged in #1639 and compile hls from source fixed it, afaik there is no compiler plugin related but template haskell

@jneira
Copy link
Member

jneira commented Oct 4, 2021

Another issue produced by ghc linker and workarounded building dinamycally hls from source

@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

7 participants