From 0fc0061b5302f516f051a599685b8be575535643 Mon Sep 17 00:00:00 2001 From: Raymond Toy <toy.raymond@gmail.com> Date: Sun, 27 Dec 2015 10:16:45 -0800 Subject: [PATCH] Disable FP traps when printing arithmetic-error messages Printing of FP numbers can signal some traps like overflow, underflow, inexact, or denormalized-operand, so we need to disable these traps when printing out the error message for arithmetic errors. --- src/code/error.lisp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/code/error.lisp b/src/code/error.lisp index 56a7d5442..0183f58c3 100644 --- a/src/code/error.lisp +++ b/src/code/error.lisp @@ -1138,9 +1138,14 @@ (format stream (intl:gettext "Arithmetic error ~S signalled.") (type-of condition)) (when (arithmetic-error-operation condition) - (format stream (intl:gettext "~%Operation was ~S, operands ~S.") - (arithmetic-error-operation condition) - (arithmetic-error-operands condition)))))) + ;; Printing the operands can signal these FP traps, so + ;; disable them while we're printing out the error + ;; message. + (with-float-traps-masked (:overflow :underflow :inexact + #+x86 :denormalized-operand) + (format stream (intl:gettext "~%Operation was ~S, operands ~S.") + (arithmetic-error-operation condition) + (arithmetic-error-operands condition))))))) (define-condition division-by-zero (arithmetic-error) ()) (define-condition floating-point-overflow (arithmetic-error) ()) -- GitLab