[GHC] #229: Integer overflow in array allocation

GHC ghc-devs at haskell.org
Fri Dec 4 01:44:54 UTC 2015


#229: Integer overflow in array allocation
-------------------------------------+-------------------------------------
        Reporter:  josefs            |                Owner:  rwbarton
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.0.1
       Component:  Core Libraries    |              Version:  7.9
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Old description:

> When asked to create a sufficiently large array ghci
> coredumps.
>
> {{{#!hs
> import Data.Array.ST
> import Control.Monad.ST
> import GHC.Base
>
> example = runST (do arr <- newArray (minInt,maxInt) False
>                     go arr)
>   where go :: STArray s Int Bool -> ST s Bool
>         go arr = readArray arr 3
> }}}
>
> Load this into ghci and type 'example'.

New description:

 When asked to create a sufficiently large array ghci
 coredumps.


 Edit: new example

 {{{#!hs
 import Data.Array.MArray
 import Data.Array.IO
 import Data.Word

 main = do
   m <- newArray_ (0,2^62-1) :: IO (IOUArray Int Word32) -- allocates 0
 bytes
   writeArray m 17 12345 -- write wherever you like
   mapM (\x -> writeArray m x 0) [1..10000] -- core dump
 }}}

 Load this into ghci and type 'main'.

--

Comment (by thomie):

 Update description with example from comment:15.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/229#comment:25>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list