Title: Stack extension
|Product: LispWorks for Linux, LispWorks for Windows|
Version: 4.1, 4.2, 4.3, 4.4
OS: Linux & Windows
Automatic stack extension is not currently supported in the PC implementation of LispWorks
In other words, hcl:extend-current-stack is not implemented.
First, keep in mind that one cause of unnecessary stack overflow is when tail
call optimization is off. To avoid this, please make sure that you
turn source debugging off with (hcl:toggle-source-debugging nil) and
set the debug optimization level to 0.
Should you really need a larger stack, a workaround is to create it initially by binding system:*sg-default-size* when creating the process, or using the :size option to
mp:process-run-function. Note that this only helps when you run multiprocessing.
If you are getting the stack overflow in a CAPI process, then binding system:*sg-default-size*is the only way because the process is created by the CAPI when you call capi:display.
Otherwise, here's an example using the :size option to mp:process-run-function :
CL-USER 1 > (defvar *count*)
CL-USER 2 > (defun recurse-to-overflow ()
(setq *count* 0)
(let ((count 0))
(labels ((recurse ()
(serious-condition ())) ; expect stack-overflow
(setq *count* count))))
CL-USER 3 > (mp:process-run-function "normal stack" '()
#<MP:PROCESS Name "normal stack" Priority 850000 State "Running">
CL-USER 4 > *count*
CL-USER 5 > (mp:process-run-function "larger stack" '(:size 30000)
#<MP:PROCESS Name "larger stack" Priority 850000 State "Running">
CL-USER 6 > *count*
In LispWorks 4.2 and later, when using the IDE, you can conveniently set the stack size for the execution process in subsequently created Listener tools, using
Listener > Preferences... > Listener > Initial Stack Size
This setting is persistant across LispWorks sessions, and is user-specific.
|See Also: |
|Summary:Extending the stack|