Skip to content

instance Read Integer/Rational/Double readsPrec out of memory and crash due to exponential notation

 GHCi, version 6.12.3: http://www.haskell.org/ghc/ 
 Loading package ghc-prim ... linking ... done.
 Loading package integer-gmp ... linking ... done.
 Loading package base ... linking ... done.
 Loading package ffi-1.0 ... linking ... done.
 120000000000
 Prelude> read "12e1000000000000" :: Integer
 Segmentation fault

Sometimes it fails with Bus error.

According to Haskell'98 and Haskell'00 Reports Integers should not parse exponential notation at all.

http://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-190002.5

This is security issue in web frameworks as parsing HTTP headers, URLs, JSON and other may involve parsing integers.

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