#5363: optimized profiled version of a program incorectly compiles $!
-------------------------------+--------------------------------------------
Reporter: phercek | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 7.0.3 | Keywords: optimization profiling stricness
Testcase: | Blockedby:
Os: Linux | Blocking:
Architecture: x86_64 (amd64) | Failure: Incorrect result at runtime
-------------------------------+--------------------------------------------
Here is a test program (file name prgSrc.hs):
{{{
import Data.Array.Unboxed
main = do
let l1 = [1..10] :: [Int]
let l2 = [ map (i+) l1 | i <- [1..5000000] ]
let l3 = map (\l -> listArray (1,length l) l) l2 :: [UArray Int Int]
print $ accumulate l3 0
accumulate [] rv = rv
accumulate (h:t) rv =
let nextRv = (rv + sum (elems h)) in
accumulate t $! nextRv
}}}
I used ghc 7.0.3-2 on archlinux, 64 bit version.
I created it only to check how much memory short unboxed arrays consume.
Thanks to the "$!" call at the last line of the "accumulate" function
there should not be any stack overflow.
When I compile with these options:[[BR]]
''ghc --make prgSrc.hs[[BR]]
ghc -O2 --make prgSrc.hs[[BR]]
ghc -prof -auto-all -caf-all --make prgSrc.hs[[BR]]''
then there is no problem.
But when I compile with these options:[[BR]]
''ghc -O2 -prof -auto-all -caf-all --make prgSrc.hs[[BR]]''
then the program runs out of stack.
This indicates that there is a bug while compiling "$!" in an optimized
profiling version of this program.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5363>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs