< Back to IRCAM Forum

STACK OVERFLOW WITH PURE LISP FUNCTION

Hello everyone

I have encountered many times the following error message in both OpenMusic and PWGL.

“An error occured : Stack overflow (stack size 261120).”

I don’t know if I’m wrong but this is related to Lispworks environment isn’t it? (both OM and PWGL are made with it now).

Until now this was happening to me with large sets of data (in analysis situations for instance)
or with heavy constraint solving algorithms.

Here I’m getting the same result with a pretty simple function (see attached).
This is only happening in OM, not in Clozure CL nor PWGL.

I understand this is sometimes related to bad programming habits, as mentioned
in recent discussions on the mailing list,
but with such a simple function and especially on a computer with 8GB of RAM
I don’t think we can talk about a lack of elegance… :slight_smile:

Is there any solution I could perform this function by raising momentarily
the memory limit? Or maybe making this option available for OM users in the preferences?

Many thanks in advance
Happy holidays
Julien

(Sorry this question was already asked “live” to Jean Bresson (I got my answer), this was a test to repost
a topic that was stuck on the server for a few months without display.
Thanks a lot Arshia for the quick fix !)

Great !

Can we see your function? the answer to it ? It could be that the answer is elsewhere…

Like if it was a recursive funciton… This would be indeed, a mater of programming. Beside, this will help Lispfolks to
optimize their programming.

Best
K

Yes Karim, here it is.

Actually we did not solve it yet with Jean, but he suggested me to take a look at
the following functions from LispWorks API (one can evaluate in the listener of OM or in a code box on PWGL for instance) :

  • (hcl::current-stack-length) displays the actual stack size
  • (hcl::extend-current-stack) evaluated many times raises the stack size to the maximum (261120 on my machine)
    But unfortunately this doesn’t help with big recursive processes…

Jean also told me that this limit came out suddenly with LW 5.1 or 6 (not sure).
The explanation given by LispWorks guys (quite hard to follow for me honestly), is the way x86 computers deal with multiprocessing.

recurs_stack_overflow.zip (8.76 KB)