Lisp Knowledgebase

Title: Stack extension

ID: 10017


Product: LispWorks for Linux, LispWorks for Windows
Version: 4.1, 4.2, 4.3, 4.4
OS: Linux & Windows

Description:
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.

Workaround:
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*)
*COUNT*


CL-USER 2 > (defun recurse-to-overflow ()
              (setq *count* 0)
              (let ((count 0))
                (labels ((recurse ()
                                  (incf count)
                                  (recurse)
                                  nil))
                  (handler-case (recurse)
                    (serious-condition ())) ; expect stack-overflow
                  (setq *count* count))))
RECURSE-TO-OVERFLOW


CL-USER 3 > (mp:process-run-function "normal stack" '()
                                     'recurse-to-overflow)
#<MP:PROCESS Name "normal stack" Priority 850000 State "Running">


CL-USER 4 > *count*
193


CL-USER 5 > (mp:process-run-function "larger stack" '(:size 30000)
                                     'recurse-to-overflow)
#<MP:PROCESS Name "larger stack" Priority 850000 State "Running">


CL-USER 6 > *count*
426



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:
Workaround:
Patch:

Hardware:N/A
Summary:Extending the stack
Bug#:
Patch Enhancement#:
Reported:5488

Company     Contact     Privacy Policy     Terms of Use