stack overflow triggered by profiling in ghc 6

Simon Marlow simonmar at microsoft.com
Fri Jul 18 10:44:38 EDT 2003


 
> 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.

While this behaviour is undesirable, I'm afraid it is entirely possible.
Compiling with profiling can, and very often does, affect the code that
gets generated - this is because in order to retain a correct cost
model, the optimiser must disable certain transformations.

Cheers,
	Simon




More information about the Glasgow-haskell-bugs mailing list