Incorrect value computed, nested ifs with <=, >=

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

Bug Description

(defparameter *form235*
   '(let ((v6
           (boole boole-xor
            (boole boole-nor 254 -8060811023048695627)
            (boole boole-nor 254
             (if a
                 0
                 -8060811023048695627)))))
     (let ((v2 (f235a (boole boole-andc1 524283 c))))
       (list v2 v6
             (if (>= v2 v6)
                 (if (<= v2 v6)
                     0
                     1)
                 2)))))

(declaim (notinline f235a))
(defun f235a (x)
  (logand #xffff x))

(defun bug235 ()
  (let* ((form *form235*)
         (lam1 `(lambda (a c)
                  ,form))
         (lam2 `(lambda (a c)
                  (declare (notinline <=))
                  ,form))
         (vals '(nil 2840466901390780041)))
    (values (apply (compile nil lam1) vals)
            (apply (compile nil lam2) vals))))

(bug235) ==> (0 0 1), (0 0 0)

x86-64, "2.3.8.144-d6ae98654"

Revision history for this message
Stas Boukarev (stassats) wrote :

Tricky to reproduce, seems indeed that something is incorrectly cached.

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

It reproduces for me on a freshly started sbcl.

Revision history for this message
Stas Boukarev (stassats) wrote :

It depends on random bits beyond an allocated bignum.

Stas Boukarev (stassats)
Changed in sbcl:
status: New → Fix Released
Revision history for this message
Paul F. Dietz (paul-f-dietz) wrote (last edit ):

> It depends on random bits beyond an allocated bignum.

Very interesting bug! Is there a way to reliably generate bignums with trash in those bits, to test for such bugs?

Revision history for this message
Stas Boukarev (stassats) wrote :

Look at the test included with the fix.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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