stack space overflow

Hal Daume t-hald@microsoft.com
Fri, 20 Jun 2003 08:04:51 -0700


Seems to work for me.  I changed it a bit (I believe you meant 'len ar'
on the first line, with the following defintion of 'len':
  len =3D (1+) . uncurry (flip (-)) . bounds
, but other than that, I left your code as it is).

Can you provide input on which it fails?  It works for me on large input
like:

*Main>  ind 1 "foo" $ listArray (1,10000) (concat $ repeat
"abcfoodefgfooa")

even in ghci.

--
 Hal Daume III                                   | hdaume@isi.edu
 "Arrest this man, he talks in maths."           | www.isi.edu/~hdaume


> -----Original Message-----
> From: haskell-admin@haskell.org=20
> [mailto:haskell-admin@haskell.org] On Behalf Of Ketil Z. Malde
> Sent: Friday, June 20, 2003 7:05 AM
> To: haskell@haskell.org
> Subject: stack space overflow
>=20
>=20
>=20
> Hi,
>=20
> I have a small function to find all indices in an array where a given
> subword can be found, looking like this:
>=20
> > ind i ws ar=20
> >   | i+length ws-1 > len e   =3D []
> >   | and [ar!(i+j) =3D=3D ws!!j | j<-[0..length ws-1]] =3D i : ind=20
> (i+1) ws ar
> >   | otherwise               =3D ind (i+1) ws ar
>=20
> (i::Int is the position, ws::[a] is the word to look for, while
> ar::Array Int a is the array wherein to look)
>=20
> This occasionally blows up with a stack overflow, perhaps I'm being
> dense, but I'm not sure why.  Any suggestions?
>=20
> 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.
>=20
> -kzm
> --=20
> If I haven't seen further, it is by standing in the=20
> footprints of giants
> _______________________________________________
> Haskell mailing list
> Haskell@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
>=20