How to add stack size when -x code to executable file

Started by ssqq, July 31, 2016, 06:03:44 AM

Previous topic - Next topic

ssqq

ERR: call or result stack overflow in function set : term

When I see this error, I think the stack size is too small. How to enlarge it in default?

rickyboy

#1
Hmmm.  I've never done this.  But before you try anything with linking, first confirm that adding more stack space will solve your issue.


$ newlisp -s 10000 foo.lsp
If something like the above works (for the appropriate value of -s, of course), only then proceed to the following



I assume you are linking your code to the newlisp executable (because you mention -x in your subject line), i.e. you are doing this:


$ newlisp -x foo.lsp foo
Have you tried the following?


$ newlisp -s 10000 -x foo.lsp foo
If that doesn't work, you could try building a version of newLISP that has the stack space you want as the default.  (This will of course mean that you will patch a bit of the C code -- probably one line, but I haven't seen the code in ages.)  Now, you should be able to link your newlisp source file with the newly built `newlisp` executable and get the extra stack space you need.
(λx. x x) (λx. x x)

ssqq

#2
I found my stack over flow is code design have problem, when call a function with recursive over 50> times, would occur this error.



> (define (call x) (cond ((= x 1) x) (true (dec x) (+ x (call x)))))
> (call 1000)
ERROR: stack over flow