[GHC] #1131: newArray_ allocates an array full of garbage
GHC
trac at galois.com
Sat Feb 3 11:28:33 EST 2007
#1131: newArray_ allocates an array full of garbage
-------------------------------+--------------------------------------------
Reporter: igloo | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 6.8
Component: libraries/base | Version: 6.6
Severity: normal | Keywords:
Difficulty: Unknown | Testcase:
Architecture: Unknown | Os: Unknown
-------------------------------+--------------------------------------------
In http://www.haskell.org/pipermail/haskell-cafe/2006-December/020115.html
Stefan O'Rear points out that newArray_ allocates an array full of
garbage. For ST this violates referential transparency, and it presumably
also means we are leaking information we shouldn't.
For example, running
{{{
import Control.Monad.ST
import Data.Array.ST
import Data.Array
import System.Mem
tickle :: Int
tickle = runST (do {
x <- newArray_ (0,100) ;
(readArray :: STUArray s Int Int -> Int -> ST s Int) x 3
})
main :: IO ()
main = do print $ length (replicate 100000 'a')
performGC
print tickle
}}}
produced
{{{
$ ./q
100000
46912506425344
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1131>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list