seg fault with List.tabulate in 3.9.1

Stephen Weeks MLton@sourcelight.com
Mon, 9 Jul 2001 11:05:04 -0700


> I'm curious if the problem with
> 	val _ = List.tabulate (1000000, fn i => i)
> segfaulting might not `just' be that they run out of stack space.  I.e., if
> they wrote this function non-tail-recursively (as opposed to 2 passes, with
> one reversing the list) then it is 10^6 non-tail calls.
> Not that this is much of an excuse.

Here is the implementation of tabulate in their sources.

  fun tabulate (n, f) =
    let fun h i = if i<n then f i :: h (i+1) else []
    in if n<0 then raise Size else h 0 
    end

So, they are doing the non-tail implementation.  Maybe you should point that out
to them.