[Ecls-list] Stack overflows

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Sun Sep 28 22:22:58 UTC 2008


Stack overflows in the binding and frame stacks are now detected. The
C stack is not yet checked (help is welcome on an efficient
implementation of this), but given that most Maxima functions use
special variables this should be more than enough for your code.

The way it works is that on overflow a correctable error is signaled.
If the user applies a CONTINUE restart, the stack is resized and
execution continues. It is not recommended to ignore the error by
using a dummy debugger function and no appropriate signal handler. The
recommended way is shown here in some dummy code

(block faa
      (labels ((foo (x)
		 (let ((*a* x))
		   (declare (special *a*))
		   (foo (1+ x))))
	       (handle-overflow (c)
		 (let ((s (ext:stack-overflow-size c)))
		   (if (< s 18000)
		       (continue)
		       (return-from faa (ext:stack-overflow-type c))))))
	(handler-bind ((ext:stack-overflow #'handle-overflow))
	  (foo 1))))

In addition to this, a new function (ext:set-stack-size type size) has
been introduced, with type being one of ext:binding-stack,
ext:frame-stack or ext:lisp-stack. The stack cannot be set to a size
smaller than the amount of records currently used, but it could be
used by Maxima to enlarge those stacks at the beginning.

Juanjo

-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28009 (Spain)
http://juanjose.garciaripoll.googlepages.com


More information about the ecl-devel mailing list