logo       

stack overflow triggered by profiling in ghc 6: msg#00040

lang.haskell.glasgow.bugs

Subject: stack overflow triggered by profiling in ghc 6

Not sure if this counts as a bug or not, but I've got the following
program:


import GHC.Exts
import Data.List

wrapper_sum xs = ub_acc_sum xs 0#
ub_acc_sum :: [Int] -> Int# -> Int
ub_acc_sum [] v = I# v
ub_acc_sum ((I# x):xs) v = ub_acc_sum xs (v +# x)

main = do
let l = take 10000000 [1,1..]
seq (last l) $ return ()
putStrLn "unboxed accum"
putStrLn $ show $ wrapper_sum l

When compiled with -O2 or -O1, and -prof and -auto-all, this runs out of
stack space. Without optimisation, it's fine: likewise, without -prof it's
fine, which seems reasonable: AFAICT, ub_acc_sum is tail-recursive.

The slight alteration

wrapper_sum xs = I# (ub_acc_sum xs 0#)
ub_acc_sum :: [Int] -> Int# -> Int#
ub_acc_sum [] v = v
ub_acc_sum ((I# x):xs) v = ub_acc_sum xs (v +# x)

is fine with all combinations of flags.

mrak

--
oh, he's like milk to you
half swedish and half asian
-- Soul Coughing


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise