Memory fault during compilation (BIGNUM related?)

Bug #2000395 reported by Paul F. Dietz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
Unassigned

Bug Description

x86-64, "2.2.11.160-65fe8bb77"

(defpackage :bug106
  (:use :common-lisp)
  (:export :bug106))

(in-package :bug106)

(defmacro int-restrict (form tp)
  (cond
    ((member tp '(integer (integer) (integer *) (integer * *)) :test 'equal)
     form)
    ((and (consp tp) (eql (car tp) 'integer) (integerp (cadr tp)) (integerp (caddr tp)))
     (let ((lo (cadr tp))
           (hi (caddr tp)))
       `(min ,hi (max ,lo ,form))))
    (t (error "Cannot handle this type in int-restrict: ~A" tp))))

(define-condition innocuous-failure (simple-condition) ()
  (:documentation "Failures that, when they occur, do not indicate the test failed"))

(define-condition require-failure (innocuous-failure) ()
  (:documentation "Error signalled by REQUIRE-TYPE when the value is not of the specified
type. This is intended to indicate that the test is bogus, not failed."))

(defparameter *require-type-passed* t
  "Set to true when CHECK-REQUIRE-TYPE succeeded. Used to indicate that checks
should be removed.")

(defun check-require-type (v tp)
  (if (typep v tp)
      (setf *require-type-passed* t)
      (signal (make-condition 'require-failure
                              :format-control "~a not of type ~a"
                              :format-arguments (list v tp)))))

(defvar *no-require-type* nil
  "Controls whether REQUIRE-TYPE inserts a type check or not")

(defmacro require-type (form tp)
  "When FORM is not of type TP, signal a REQUIRE-FAILURE condition that indicates
the test was bad. When the special variable *NO-REQUIRE-TYPE* is true, omit
the check."
  (if *no-require-type*
      form
      (let ((form-var (gensym)) (tp-var (gensym)))
        `(let ((,form-var ,form)
               (,tp-var ',tp))
           (check-require-type ,form-var ,tp-var)
           ,form-var))))

(defun f (b)
   (declare (notinline / rational +))
   (+
    (rational
     (/
      (/
       (int-restrict
        (require-type (setq b (int-restrict b (integer -4397321656545 38967)))
                      (integer 2924 17130674429247916))
        (integer -4397321656545 38967))
       -1)
      -1))
    b))

==>

CORRUPTION WARNING in SBCL pid 40056 tid 40056:
Memory fault at 0x7ffa997fff1 (pc=0x52a2dc9c [code 0x52a2bf40+0x1D5C ID 0x1d9f], fp=0x7f59d73fe718, sp=0x7f59d73fe6a0) tid 40056
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
While evaluating the form starting at line 50, column 0
  of #P"/home/pdietz/ansi-test/bugs/bug106.lisp":

debugger invoked on a SB-SYS:MEMORY-FAULT-ERROR in thread
#<THREAD "main thread" RUNNING {10010A0003}>:
  Unhandled memory fault at #x7FFA997FFF1.

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

restarts (invokable by number or by possibly-abbreviated name):
  0: [RETRY ] Retry EVAL of current toplevel form.
  1: [CONTINUE] Ignore error and continue loading file "/home/pdietz/ansi-test/bugs/bug106.lisp".
  2: [ABORT ] Abort loading file "/home/pdietz/ansi-test/bugs/bug106.lisp".
  3: Exit debugger, returning to top level.

(SB-BIGNUM:BIGNUM-INTEGER-LENGTH 4397321682944)
0]

Revision history for this message
Paul F. Dietz (paul-f-dietz) wrote :

Note that 4397321682944 is not a BIGNUM.

Stas Boukarev (stassats)
Changed in sbcl:
status: New → Fix Committed
Stas Boukarev (stassats)
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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