Wrong result for integer comparison

Bug #1971088 reported by Guillaume LE VAILLANT
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
Unassigned

Bug Description

I have a strange error with SBCL 2.2.4 on GNU/Linux x86_64 when running the
test suite of the lzlib library (https://github.com/glv2/cl-lzlib).
There is no error with SBCL 2.2.2.

The error can be reproduced with:

    (ql:quickload "lzlib")
    (lzlib::lzma-options 6 8388608 36)

    debugger invoked on a LZLIB:LZLIB-ERROR in thread
    #<THREAD "main thread" RUNNING {1004C30113}>:
      DICTIONARY-SIZE must be between 4096 and 536870912.

The code the error comes from is:

    (defun lzma-options (level dictionary-size match-len-limit)
      (cond
        [...]
        ((and dictionary-size match-len-limit)
         (let ((min-dictionary-size (lz-min-dictionary-size))
               (max-dictionary-size (lz-max-dictionary-size))
               [...])
           (cond
             ((not (and (integerp dictionary-size)
                        (<= min-dictionary-size
                            dictionary-size
                            max-dictionary-size)))
              (lz-error "DICTIONARY-SIZE must be between ~d and ~d."
                        min-dictionary-size
                        max-dictionary-size))
             [...])))))

So it looks like the form:
    (<= min-dictionary-size dictionary-size max-dictionary-size)
which in this case is equivalent to:
    (<= 4096 8388608 536870912)
returned NIL instead of T.

The lz-min-dictionary-size and lz-max-dictionary-size functions are foreign
functions defined as:

    (deftype i32 () '(signed-byte 32))

    (declaim (ftype (function () i32) lz-min-dictionary-size))
    (cffi:defcfun ("LZ_min_dictionary_size" lz-min-dictionary-size) :int)

    (declaim (ftype (function () i32) lz-max-dictionary-size))
    (cffi:defcfun ("LZ_max_dictionary_size" lz-max-dictionary-size) :int)

If the calls to lz-min-dictionary-size and lz-max-dictionary-size are replaced
in the code for lzma-options above by the values they return, or by CL
functions returning the same values, the error disappears.

Stas Boukarev (stassats)
Changed in sbcl:
assignee: nobody → Stas Boukarev (stassats)
status: New → Confirmed
Stas Boukarev (stassats)
Changed in sbcl:
status: Confirmed → Fix Committed
assignee: Stas Boukarev (stassats) → nobody
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.