Subject: Re: Prolog Out of Stack Error!

From: Jan Wielemaker <[email-masked]>
Date: Thu, 31 Aug 2000 10:52:37 +0200

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