Skip to content

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

Closed
@peterwicksstringfield

Description

@peterwicksstringfield

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    can-workaroundtype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions