From jan@swi.psy.uva.nl  Thu Aug 31 10:58:18 2000
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id KAA06564;
	Thu, 31 Aug 2000 10:58:18 +0200 (MET DST)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id KAA27176;
	Thu, 31 Aug 2000 10:58:23 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: Lalit Jain <lalit@savvion.com>, prolog@swi.psy.uva.nl
Subject: Re: Prolog Out of Stack Error!
Date: Thu, 31 Aug 2000 10:52:37 +0200
X-Mailer: KMail [version 1.0.28]
Content-Type: text/plain
References: <Pine.GSO.4.21.0008301827440.23697-100000@neptune.tdiinc.com>
In-Reply-To: <Pine.GSO.4.21.0008301827440.23697-100000@neptune.tdiinc.com>
MIME-Version: 1.0
Message-Id: <00083110582300.27133@gollem>
Content-Transfer-Encoding: 8bit

On Thu, 31 Aug 2000, Lalit Jain wrote:
>Hi:
>I am running the Prolog engine within a Java RMI Server.
>The Server processes the first request fine but always fails in the second
>request after the Prolog engine crashes due to "Out of local stack".
>
>The error dump is as follows:
>
>ERROR: Out of local stack while not in Prolog!?
>Assertion failed: 0, file ./pl-alloc.c, line 331
>SIGABRT 6 abort (generated by abort(3) routine)
>    si_signo [6]: ABRT
>    si_errno [0]: 
>    si_code [-1]: SI_LWP [pid: 10401, uid: 2160]
>        stackpointer=EE64F3D8
>
>Inconsistent thread : best efforts attempt (may fail)
>"RMI TCP Connection(6)-10.1.4.46" (TID:0x5b7bd8, sys_thread_t:0x5b7b18,
>state:R, thread_t: t@16, threadID:0xee651dd8, stack_bottom:0xee652000,
>stack_size:0x20000) prio=5 *current thread*
>
>Does anybody have a clue as to what might be wrong?
>What could be the potential cause for Prolog's " ERROR: Out of local stack
>while not in Prolog!? ". 

I don't know your setup, but a likely cause is that
term-references (term_t) keep building up.  term-references are
reclaimed as soon as the scope in which they are created ends.
Prolog calling C runs the C-code `in a scope' and you can make
them explicitly using PL_open_foreign_frame() and
PL_close_foreign_frame() or PL_destroy_foreign_frame().  If you
use Prolog only from C, at some stage you allocate a term-reference
and you are out of local stack.  So Prolog runs out of stack while
there are no Prolog goals on the stack.  Prolog is not very happy
about that as it has no place to deliver the exception.

	Regards --- Jan

