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

Q&A's, tips, howto's

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

Postby ssqq » Sun Jul 31, 2016 1:03 pm

Code: Select all
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?
ssqq
 
Posts: 88
Joined: Sun May 04, 2014 12:49 pm

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

Postby rickyboy » Fri Aug 05, 2016 12:45 pm

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

Code: Select all
$ 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:

Code: Select all
$ newlisp -x foo.lsp foo

Have you tried the following?

Code: Select all
$ 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)
rickyboy
 
Posts: 595
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

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

Postby ssqq » Fri Aug 05, 2016 5:11 pm

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

Code: Select all
> (define (call x) (cond ((= x 1) x) (true (dec x) (+ x (call x)))))
> (call 1000)
ERROR: stack over flow
ssqq
 
Posts: 88
Joined: Sun May 04, 2014 12:49 pm


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 2 guests