1.0.27.37: fix host constant leaks
authorChristophe Rhodes <csr21@cantab.net>
Fri, 24 Apr 2009 13:11:22 +0000 (13:11 +0000)
committerChristophe Rhodes <csr21@cantab.net>
Fri, 24 Apr 2009 13:11:22 +0000 (13:11 +0000)
Various ways in which a host constant can leak through the
cross-compiler into the target are plugged.

5 commit messages follow:

fix host most-positive-fixnum leak in declaration

Found by comparing object code for SORT-VECTOR between clisp and sbcl xc
hosts.

Fix most-fooative-fixnum leak in number-psxhash

Gah, floats.  Most cases will be more complicated to fix than this one.
(Fixing things absolutely properly would be hugely difficult; this fix
should do for now...)

more careful cross-compiler constant-form-value

We need to take values from the xc info database in preference to using
SYMBOL-VALUE, otherwise we'll leak from the host.  (In particular, this
one was for function in debug.lisp with lambda lists of the
form (&optional (n most-positive-fixnum))

deal with another host fixnum-related constant leak

This time it's in the definition of the integer constants which are both
fixnums and exactly representable as floats.  Amazingly, just above
these definitions are the ones for SB!XC:MOST-POSITIVE-FIXNUM and
friends; no alarm bells were ringing...

fix a fixnum leak in unix-fd type

This mistake [ (deftype foo () `(integer 0 ,most-positive-fixnum)) ]
seems distressingly easy to make.  Not easy to guard against, either.
(Aside: is it sensible to define FDs as positive fixnums?)

src/code/target-sxhash.lisp
src/code/unix.lisp
src/compiler/constantp.lisp
src/compiler/generic/early-vm.lisp
src/compiler/srctran.lisp
version.lisp-expr

index 28bbf84..a3e09b4 100644 (file)
     (etypecase key
       (integer (sxhash key))
       (float (macrolet ((frob (type)
-                          (let ((lo (coerce most-negative-fixnum type))
-                                (hi (coerce most-positive-fixnum type)))
+                          (let ((lo (coerce sb!xc:most-negative-fixnum type))
+                                (hi (coerce sb!xc:most-positive-fixnum type)))
                             `(cond (;; This clause allows FIXNUM-sized integer
                                     ;; values to be handled without consing.
                                     (<= ,lo key ,hi)
index 7033fee..224911a 100644 (file)
@@ -48,7 +48,7 @@
 ;;;; Lisp types used by syscalls
 
 (deftype unix-pathname () 'simple-string)
-(deftype unix-fd () `(integer 0 ,most-positive-fixnum))
+(deftype unix-fd () `(integer 0 ,sb!xc:most-positive-fixnum))
 
 (deftype unix-file-mode () '(unsigned-byte 32))
 (deftype unix-pid () '(unsigned-byte 32))
index 85bb5b8..1468534 100644 (file)
                   form)))
     (typecase form
       (symbol
-       (symbol-value form))
+       ;; KLUDGE: superficially, this might look good enough: we grab
+       ;; the value from the info database, and if it isn't there (or
+       ;; is NIL, but hey) we use the host's value.  This works for
+       ;; MOST-POSITIVE-FIXNUM and friends, but still fails for
+       ;; float-related constants, where there is in fact no guarantee
+       ;; that we can represent our target value at all in the host,
+       ;; so we don't try.  We should rework all uses of floating
+       ;; point so that we never try to use a host's value, and then
+       ;; make some kind of assertion that we never attempt to take
+       ;; a host value of a constant in the CL package.
+       #+sb-xc-host (or (info :variable :xc-constant-value form)
+                        (symbol-value form))
+       #-sb-xc-host (symbol-value form))
       (list
        (if (special-operator-p (car form))
            (constant-special-form-value form environment envp)
index 2a39fc3..feb1abd 100644 (file)
   "the fixnum closest in value to negative infinity")
 
 (def!constant most-positive-exactly-single-float-fixnum
-  (min #xffffff most-positive-fixnum))
+  (min #xffffff sb!xc:most-positive-fixnum))
 (def!constant most-negative-exactly-single-float-fixnum
-  (max #x-ffffff most-negative-fixnum))
+  (max #x-ffffff sb!xc:most-negative-fixnum))
 (def!constant most-positive-exactly-double-float-fixnum
-  (min #x1fffffffffffff most-positive-fixnum))
+  (min #x1fffffffffffff sb!xc:most-positive-fixnum))
 (def!constant most-negative-exactly-double-float-fixnum
-  (max #x-1fffffffffffff most-negative-fixnum))
+  (max #x-1fffffffffffff sb!xc:most-negative-fixnum))
 
 ;;;; Point where continuous area starting at dynamic-space-start bumps into
 ;;;; next space.
index 49616d4..10987c2 100644 (file)
                        (start-1 (1- ,',start))
                        (current-heap-size (- ,',end ,',start))
                        (keyfun ,keyfun))
-                   (declare (type (integer -1 #.(1- most-positive-fixnum))
+                   (declare (type (integer -1 #.(1- sb!xc:most-positive-fixnum))
                                   start-1))
                    (declare (type index current-heap-size))
                    (declare (type function keyfun))
index 963a79e..e63ce82 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.27.36"
+"1.0.27.37"