unbound slot in division-by-zero and other FP exception conditions
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Confirmed
|
Low
|
Unassigned |
Bug Description
Reported by Gabriel Dos Reis on sbcl-devel:
The form exposes a bug in the SBCL DIVISION-BY-ZERO class.
;; --- cut here
(defun invert-x (x) (/ 1 x))
(defun handle-div-by-zero (c)
(let ((op (arithmetic-
(args (arithmetic-
(format *error-output* "op = ~A, args = ~A ~%" op args)
(throw 'result "failed")))
(defun invert (x)
(handler-bind ((division-by-zero #'handle-
(invert 0) ;; OK -- returns "failed"
(invert 0.0) ;; KO -- drops into debugger
;; -- cut here
On gets dropped into the debugger:
debugger invoked on a SIMPLE-ERROR: unbound condition slot: SB-KERNEL::OPERANDS
Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
restarts (invokable by number or by possibly-
0: [ABORT] Exit debugger, returning to top level.
(SB-KERNEL:
#<SB-KERNEL:
#S(SB-
:NAME SB-KERNEL::OPERANDS
:INITARGS (:OPERANDS)
:READERS (ARITHMETIC-
:WRITERS NIL
:INITFORM-P NIL
:INITFORM NIL
:ALLOCATION :INSTANCE
:CELL NIL
:DOCUMENTATION NIL))
0]
tags: |
added: floating-point removed: fp |
The bug resides in src/code/ float-traps. lisp:
(defun sigfpe-handler (signal info context) :siginfo- code info))) interrupts code-error- alist*) )
'floating- point-exception )))))
(declare (ignore signal context))
(declare (type system-area-pointer info))
(let ((code (sb!unix:
(with-
(error (or (cdr (assoc code *sigfpe-
We signal the error without providing either :operation or :operands.
Since all conditions signalled are subclasses or ARITHMETIC-ERROR, that's a bit suboptimal.
Getting access to operation for DIVISION-BY-ZERO is a no-brainer (we can always call it /), for the others it requires parsing the offending instruction -- ditto for operands.
Perhaps defaulting both to NIL is an acceptable least-evil for now?