On Sun, Jul 27, 2008 at 10:52 PM, Michael Weber <michaelw+sbcl@...> wrote:
> Executing the following code crashes SBCL reliably for me:
> (defun foo ()
> ((bar (lambda ()
> (return-from foo 42))
> (lambda (condition)
> (find-restart 'qux))))
> (when (find-restart 'bar)
> (invoke-restart 'bar))))
> (foo) should return NIL. If I replace (find-restart 'qux) with NIL or
> T, the crash goes away.
FIND-RESTART in the test-function causes infinite recursion, which
hits the stack guard page. Then the debugger tries to figure out the
restarts, hitting the same trap, and SBCL dies.
The version below fixes this by removing the restart whose
test-function is being called from consideration.
(defvar *restart-test-stack* nil)
(defun compute-restarts (&optional condition)
"Return a list of all the currently active restarts ordered from most recently
established to less recently established. If CONDITION is specified, then only
restarts associated with CONDITION (or with no condition) will be returned."
(let ((associated ())
(dolist (alist *condition-restarts*)
(if (eq (car alist) condition)
(setq associated (cdr alist))
(setq other (append (cdr alist) other))))
(let ((stack *restart-test-stack*))
(declare (optimize sb!c::stack-allocate-dynamic-extent))
(dolist (cluster *restart-clusters*)
(dolist (restart cluster)
(when (and (or (not condition)
(member restart associated :test #'eq)
(not (member restart other :test #'eq)))
(not (member restart stack :test #'eq))
(let ((*restart-test-stack* (cons restart stack)))
(declare (dynamic-extent *restart-test-stack*))
(funcall (restart-test-function restart) condition)))
> I tested with:
> * OSX 10.5.4, SBCL 18.104.22.168 and 1.0.18 (22.214.171.124 does not build for
> me, see <http://paste.lisp.org/display/64320>), 32-bit, threads
I cannot reproduce this build error. Is this a clean checkout?
Anything wierd in the environment?