From jan@swi.psy.uva.nl  Wed Nov  3 10:06:14 1999
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.114.15])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id KAA13379;
	Wed, 3 Nov 1999 10:06:13 +0100 (MET)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.9.3/8.9.3) id KAA26205;
	Wed, 3 Nov 1999 10:06:16 +0100
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: "Noord G.J.M. van" <vannoord@let.rug.nl>
Subject: Re: SWI: reading in large terms: local stack overflow
Date: Wed, 3 Nov 1999 09:59:39 +0100
X-Mailer: KMail [version 1.0.21]
Content-Type: text/plain
References: <14367.23051.316944.273014@froh.let.rug.nl>
Cc: prolog@gollem.swi.psy.uva.nl
MIME-Version: 1.0
Message-Id: <99110310061600.26132@gollem>
Content-Transfer-Encoding: 8bit

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

