Stack overflow with Data.Binary

Grzegorz grzegorz.chrupala at
Mon Jun 4 11:05:56 EDT 2007

I just spent some time trying to find a stack overflow bug. I seem to have
narrowed it down to somewhere probably related to the default Binary instances.

It only seems to overflow when compiling with -prof. The following is a
reasonably minimal example.

Any ideas of what might be going on?

-- foo.hs 
-- compiled with:
-- ghc  -O2  -prof --make foo.hs

-- $ ./foo  < okok
-- Stack space overflow: current size 8388608 bytes.
-- Use `+RTS -Ksize' to increase it.

import Data.IntMap
import qualified Data.ByteString.Lazy as BS
import Data.Binary 

main = do
  s <- BS.getContents
  print . size  . snd $ (decode $ s::(IntMap Double,IntMap (Int,Maybe String)))


More information about the Libraries mailing list