[Ecls-list] errors happening in handler silently muffled

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Sun Feb 7 19:48:30 UTC 2010


On Sun, Feb 7, 2010 at 5:18 PM, Tobias C. Rittweiler <tcr at freebits.de>wrote:

> Well, trying it again, this will now get me into ECL's native debugger
> which probably means that you forgot to heed *DEBUGGER-HOOK*.
> <https://lists.sourceforge.net/lists/listinfo/ecls-list>
>

Your presumptions are wrong. Your code

(handler-bind ((condition
                #'(lambda (c)
                    (format "~&Caught: ~S => ~A~%" c c))))
 (compile-file "/tmp/frob.lisp"))

contains an error in the handler. That handler is invoked in a context in
which the compiler handlers are not active, because this binding is an outer
one. This means the error is not muffled (as you wanted) but it also means
that the error is not just collected and printed, because the compiler error
handler is not active. Hence the debugger is entered.

I do not bind *debugger-hook* in the compiler because that is not a coherent
and comprehensive way of handling errors. Error handling in the compiler is
done using handler bindings,

(defmacro with-compiler-env ((compiler-conditions) &body body)
  `(let ((*compiler-conditions* nil))
     (declare (special *compiler-conditions*))
     (restart-case
 (handler-bind ((compiler-note #'handle-compiler-note)
(warning #'handle-compiler-warning)
(compiler-error #'handle-compiler-error)
                        (compiler-internal-error
#'handle-compiler-internal-error)
                        (serious-condition
#'handle-compiler-internal-error))
           (mp:with-lock (mp::+load-compile-lock+)
             (let ,+init-env-form+
               (with-compilation-unit ()
                 , at body))))
       (abort ()))
     (setf ,compiler-conditions *compiler-conditions*)))

This approach is very similar to SBCL's but is organized in a way that
compilation units can be nested. Here HANDLE-COMPILER-INTERNAL-ERROR is the
routine that normally just collects errors and jumps to the ABORT restart.

Juanjo

-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20100207/4dcb40b0/attachment.html>


More information about the ecl-devel mailing list