4

The Haskell program

main=main>>main

fails with

2mem: Stack space overflow: current size 33624 bytes.
2mem: Use `+RTS -Ksize -RTS' to increase it.

33k seems quite small. The OS (via top) is reporting a total memory usage of 6G before failing. When I compile the program with ghc -rtsopts 2mem.hs and run it with ./2mem +RTS -K32M I sill get the same error.

I'm using ghc, version 8.0.1 on MacOS 10.11.6.

Why is the stack space so small and why doesn't -K32M increase it?

4
  • It hardly matters. Your program will blow the stack no matter how you run it. It's basically the same as main = main, but the later will produce a <<loop>> exception instead of a stack overflow. 33K is a pretty large stack for the way GHC uses it. Commented Dec 1, 2016 at 22:05
  • The reported stack size in the message is wrong. I thought this got fixed though. Commented Dec 1, 2016 at 22:09
  • 1
    @ReidBarton: a bug in ghc, maybe this one, although it is marked as "fixed"? Anyone familiar with the ghc bug tracking system? Is there a way to re-open a ticket? Commented Dec 1, 2016 at 22:36
  • Yes that's the one I was thinking of. I reopened the ticket. Commented Dec 1, 2016 at 22:47

1 Answer 1

3

It's a bug in GHC; the reported stack size in the message is wrong. See https://ghc.haskell.org/trac/ghc/ticket/10445 and thanks for noticing that it's not actually fixed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.