Skip to content

ghc: internal error: allocation of 2099240 bytes too large

Summary

GHCi crashes when issued :show-bindings.

Steps to reproduce

The following produces a crash

$ cabal repl -w ghc-8.10
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details):
 - haskell-odbc-0.1.0.0 (lib:lane-stuff) (first run)
Preprocessing library 'lane-stuff' for haskell-odbc-0.1.0.0..
GHCi, version 8.10.2: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/andrea/.ghci
[1 of 3] Compiling Lanes.Types      ( Lanes/Types.hs, interpreted )
[2 of 3] Compiling Lanes.IO         ( Lanes/IO.hs, interpreted )
[3 of 3] Compiling Lanes            ( Lanes.hs, interpreted )
Ok, three modules loaded.
λ> lpps <- readFile 
λ> :show bindings 
lpps :: Data.Vector.Vector MyData = _
λ> length lpps
137473
λ> :show bindings 
ghc: internal error: allocation of 2099240 bytes too large (GHC should have complained at compile-time)
    (GHC version 8.10.2 for x86_64_unknown_linux)
    Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug
cabal: repl failed for lib:lane-stuff from haskell-odbc-0.1.0.0. The build
process terminated with exit code -6

Note that only the second call to :show bindings fails. The readFile function simply reads a csv file with Cassava.

readFile :: IO (Vector MyData)
readFile = do
  bs <- LBS.readFile "mydatafile.csv"
  let Right (_, v) = decodeByName bs
  pure v

The file mydatafile.csv is 7MB in size. Unfortunately I cannot share it.

Expected behavior

I expect GHCi not to crash.

Environment

  • GHC version used: 8.10.2 (ghcup)

Optional:

  • Operating System: Ubuntu
  • System Architecture: x86

https://mpickering.github.io/ide/posts/2020-08-04-measuring-memory-size.html seems relevant, it points to #12492 (closed) but that seems to be related to ghc-heap-view or ghc-datasize which should not be at play here.

Edited by Ben Gamari
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information