[eclipse-users] Stack overflow in simple example

From: <DougPatterson.49193539_at_bloglines.com>
Date: 29 Apr 2007 10:59:21 -0000
Hi,



I am teaching myself Prolog and Eclipse by trying to solve simple problems.
In a recent puzzle[1] I was consistently getting stack overflow errors, which
I narrowed down to this line of code (run from DosEclipse):



[eclipse 67]:
lib(ic), length(Xs, 3), Xs :: [0, 9^9].

*** Overflow of the global/trail
stack in spite of garbage collection!

You can use the "-g kBytes" (GLOBALSIZE)
option to have a larger stack.

Peak sizes were: global stack 131008 kbytes,
trail stack 4160 kbytes

Abort



I managed to work around this (I didn't
need every digit of 9^9, just the first and last) but would like to understand
the problem so that I can avoid it in future. Could anyone explain the underlying
mechanism that leads to the stack overflow?



I also noted that:



[eclipse
68]: Xs :: [0, 9^9].



Xs = Xs{[0, 387420489]}

Yes (0.14s cpu)



takes
measurably longer to run than:



[eclipse 69]: Xs :: [0..9^9].



Xs = Xs{0
.. 387420489}

Yes (0.00s cpu)



Why is that?



Thanks in advance for any
insights,



Doug



[1] http://www.colinamorris.com/enigma/view_enigma.php?id=1439
Received on Sun Apr 29 2007 - 11:59:26 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET