[cmucl-cvs] CMUCL commit: src (code/seq.lisp general-info/release-20c.txt)
Raymond Toy
rtoy at common-lisp.net
Thu Dec 9 05:13:51 UTC 2010
Date: Thursday, December 9, 2010 @ 00:13:51
Author: rtoy
Path: /project/cmucl/cvsroot/src
Modified: code/seq.lisp general-info/release-20c.txt
SUBSEQ was sometimes crashing lisp when the end index was less than
the start. This was due to one of two things: The result sequence
was created with a negative length, creating invalid objects, or
accessing the invalid object would cause a segfault.
code/seq.lisp:
o Declare the type of LENGTH in MAKE-SEQUENCE-OF-TYPE better. It's
not a fixnum, but an index (non-negative fixnum). This should catch
any mistakes where we try to create sequences of negative length.
o Explicitly catch invalid START and END indices in VECTOR-SUBSEQ* and
LIST-SUBSEQ* and signal an error
general-info/release-20c.txt:
o Document bugfix.
------------------------------+
code/seq.lisp | 8 ++++++--
general-info/release-20c.txt | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)
Index: src/code/seq.lisp
diff -u src/code/seq.lisp:1.58 src/code/seq.lisp:1.59
--- src/code/seq.lisp:1.58 Tue Apr 20 13:57:45 2010
+++ src/code/seq.lisp Thu Dec 9 00:13:50 2010
@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(ext:file-comment
- "$Header: /project/cmucl/cvsroot/src/code/seq.lisp,v 1.58 2010-04-20 17:57:45 rtoy Rel $")
+ "$Header: /project/cmucl/cvsroot/src/code/seq.lisp,v 1.59 2010-12-09 05:13:50 rtoy Exp $")
;;;
;;; **********************************************************************
;;;
@@ -124,7 +124,7 @@
(defun make-sequence-of-type (type length)
"Returns a sequence of the given TYPE and LENGTH."
- (declare (fixnum length))
+ (declare (type index length))
(case (type-specifier-atom type)
(list (make-list length))
((bit-vector simple-bit-vector) (make-array length :element-type '(mod 2)))
@@ -285,6 +285,8 @@
(defun vector-subseq* (sequence start &optional end)
(declare (vector sequence) (fixnum start))
(when (null end) (setf end (length sequence)))
+ (unless (<= start end)
+ (error "Illegal bounding indices: ~S ~S" start end))
(do ((old-index start (1+ old-index))
(new-index 0 (1+ new-index))
(copy (make-sequence-like sequence (- end start))))
@@ -294,6 +296,8 @@
(defun list-subseq* (sequence start &optional end)
(declare (list sequence) (fixnum start))
+ (when (and end (> start (the fixnum end)))
+ (error "Illegal bounding indices: ~S ~S" start end))
(if (and end (>= start (the fixnum end)))
()
(let* ((groveled (nthcdr start sequence))
Index: src/general-info/release-20c.txt
diff -u src/general-info/release-20c.txt:1.13 src/general-info/release-20c.txt:1.14
--- src/general-info/release-20c.txt:1.13 Thu Dec 2 09:26:45 2010
+++ src/general-info/release-20c.txt Thu Dec 9 00:13:50 2010
@@ -85,6 +85,9 @@
- FORMAT signals an warning if ~:; is used inside ~:[.
- SET-SYSTEM-EXTERNAL-FORMAT was not actually setting the filename
encoding if given.
+ - SUBSEQ with an end index less than the start index sometimes
+ crashes CMUCL. Now, signal an error if the boudns are not
+ valid.
* Trac Tickets:
More information about the cmucl-cvs
mailing list