2011-05-23 23:55:44 |
Paul Khuong |
description |
;; SB-IMPL::ROUND-BYTES-TO-WORDS
;; sbcl/src/code/run-program.lisp
Though the likelihood of something like the following occuring is prob. less
than realistic, it is the case that where N is a fixnum near the boundaries
of CL:MOST-POSITIVE-FIXNUM that the addition of N to (1- ,bytes-per-word) may
overflow the value of CL:MOST-POSITIVE-FIXNUM causing the second fixnum
assertion to fail erroneously, e.g.:
(sb-impl::round-bytes-to-words (1- most-positive-fixnum))
(macroexpand-1 '(sb-impl::round-bytes-to-words (1- most-positive-fixnum)))
Also, when is it permissible for the byte N to be a negative integer?
(defmacro tt--round-bytes-to-words (n)
(let ((bytes-per-word (/ sb-vm:n-machine-word-bits sb-vm:n-byte-bits)))
`(logandc2 (the fixnum (+ (the fixnum ,n)
(1- ,bytes-per-word))) (1- ,bytes-per-word))))
--
/s_P\ |
RUN-PROGRAM can fail spuriously when given long (on the same order of magnitude as ARRAY-TOTAL-SIZE-LIMIT) argument strings.
Test cases for 32 bit builds with enough memory:
(run-program "/bin/echo" (list (make-array (1- array-total-size-limit)
:element-type 'base-char
:initial-element #\a)))
(run-program "/bin/echo" (list (make-array (- array-total-size-limit 2)
:element-type 'base-char
:initial-element #\a))) |
|