Compiling forms containing literal NaNs causes FLOATING-POINT-INVALID-OPERATION on high debug/safety

Bug #1909881 reported by Michał "phoe" Herda on 2021-01-02
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
SBCL
Undecided
Unassigned

Bug Description

SBCL 2.1.0 on Linux amd64.

* (describe-compiler-policy)
  Basic qualities:
COMPILATION-SPEED = 1
DEBUG = 3
SAFETY = 3
SPACE = 1
SPEED = 1
INHIBIT-WARNINGS = 1
  Dependent qualities:
SB-C::CHECK-CONSTANT-MODIFICATION = 1 -> 3 (yes)
SB-C::TYPE-CHECK = 1 -> 3 (full)
SB-C::CHECK-TAG-EXISTENCE = 1 -> 3 (yes)
SB-C::LET-CONVERSION = 1 -> 0 (off)
SB-C:ALIEN-FUNCALL-SAVES-FP-AND-PC = 1 -> 3 (yes)
SB-C:VERIFY-ARG-COUNT = 1 -> 3 (yes)
SB-C::INSERT-DEBUG-CATCH = 1 -> 3 (yes)
SB-C::RECOGNIZE-SELF-CALLS = 1 -> 0 (no)
SB-C::FLOAT-ACCURACY = 1 -> 3 (full)
SB-C:INSERT-STEP-CONDITIONS = 1 -> 3 (full)
SB-C::COMPUTE-DEBUG-FUN = 1 -> 3 (yes)
SB-C:STORE-SOURCE-FORM = 1 -> 3 (yes)
SB-C::PRESERVE-SINGLE-USE-DEBUG-VARIABLES = 1 -> 3 (yes)
SB-C::INSERT-ARRAY-BOUNDS-CHECKS = 1 -> 3 (yes)
SB-C::STORE-XREF-DATA = 1 -> 3 (yes)
SB-C:STORE-COVERAGE-DATA = 1 -> 0 (no)
SB-C::INSTRUMENT-CONSING = 1 -> 1 (no)
SB-C::STORE-CLOSURE-DEBUG-POINTER = 1 -> 0 (no)
SB-KERNEL:ALLOW-NON-RETURNING-TAIL-CALL = 1 -> 0 (no)

* (compile nil (lambda () (cl:define-symbol-macro foo #.(sb-kernel:make-single-float -1))))

debugger invoked on a FLOATING-POINT-INVALID-OPERATION in thread
#<THREAD "main thread" RUNNING {1004A684B3}>:
  arithmetic error FLOATING-POINT-INVALID-OPERATION signalled
Operation was (> #<SINGLE-FLOAT quiet NaN> #<SINGLE-FLOAT quiet NaN>).

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-KERNEL:TWO-ARG-> #<SINGLE-FLOAT quiet NaN> #<SINGLE-FLOAT quiet NaN>)

Michał "phoe" Herda (phoe-krk) wrote :

Issue moved over from https://github.com/brown/protobuf/issues/21

Seems like SBCL on high safety/debug is trying to make a numeric type out of two NaNs and calls #'> on them, which causes a FPU trap and signals an error.

Michał "phoe" Herda (phoe-krk) wrote :

This fails also on default optimization settings and also on SBCL 2.0.10.

Minimum reproducible error: (compile nil (lambda () #.(sb-kernel:make-single-float -1)))

Douglas Katzman (dougk) on 2021-01-12
Changed in sbcl:
status: New → Fix Committed
summary: - DEFINE-SYMBOL-MACRO with literal NaN causes FLOATING-POINT-INVALID-
+ Compiling forms containing literal NaNs causes FLOATING-POINT-INVALID-
OPERATION on high debug/safety
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.