Skip to content

Wrong stack space size when using -Ksize

After compiling the first example in https://wiki.haskell.org/Performance/Accumulating_parameter:

$ cat Test.hs

len :: [a] -> Int
len []     = 0
len (x:xs) = len xs + 1

main :: IO ()
main = print $ len [1..1000000]
$ ghc Test.hs -rtsopts

and running

./Test +RTS -K10K

GHC 7.6.3 reports

Stack space overflow: current size 10240 bytes.

GHC 7.8.4 reports

Stack space overflow: current size 33632 bytes.

GHC 7.10.1 reports

Stack space overflow: current size 99136 bytes.

and GHC 7.10.2, 7.10.3. 8.0.1 and 8.0.2-rc1 report

Stack space overflow: current size 33624 bytes.

GHC >= 7.8.4 report an incorrect stack space size.

Edited by Andrés Sicard-Ramírez
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information