Subject: Re: SWI: reading in large terms: local stack overflow

From: Jan Wielemaker <[email-masked]>
Date: Wed, 3 Nov 1999 09:59:39 +0100

On Tue, 02 Nov 1999, you wrote:
>Another one ;-)
>
>I run out of local stack when reading in a single large term from a
>file. Setting -L doesn't seem to help. Perhaps there is a hard limit
>to the size of a single term to be read? If so, is there a
>work-around? Size of my example is almost 40K; allocated local stack
>is 32K after crash...

Basically, that is why you'd like to have the mapped stacks.  Without,
the system uses a stack-shifter, but due to the design, this can only
be called safely at the call-port, and you never know how much rubbish
will be created before the next call-port (read/1 is a bit sloppy in
using foreign term-references which are temporary allocated on the
local stack).

There is a hack around: use stack_parameter/4 to set the `min_free'
attribute.

Comming back to this problem: try to compile with mapped-stacks but
using --disable-segv-handling.  That uses mmap() for allocation
(and thus no shifter), but doesn't use handling the SEGV signal for
guarding the stack limits.  On some systems handling SEGV and
returning from the handler is not supported at all or unrelyable.

Please let me know your findings, so I can add a remark.

	--- Jan