stack space overflow

Ketil Z. Malde ketil@ii.uib.no
20 Jun 2003 16:04:44 +0200


Hi,

I have a small function to find all indices in an array where a given
subword can be found, looking like this:

> ind i ws ar 
>   | i+length ws-1 > len e   = []
>   | and [ar!(i+j) == ws!!j | j<-[0..length ws-1]] = i : ind (i+1) ws ar
>   | otherwise               = ind (i+1) ws ar

(i::Int is the position, ws::[a] is the word to look for, while
ar::Array Int a is the array wherein to look)

This occasionally blows up with a stack overflow, perhaps I'm being
dense, but I'm not sure why.  Any suggestions?

BTW, is there a general way to track down stack overflows?  I use the
-xc option, are there any other tricks I should know about?  And does
heap profiling (GHC) imply more stack usage -- I seem to get overflows
much more easily when profiling.

-kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants