Remove more assumptions of implicit 0-fill for all vectors

Most of these were genuinely using elements that were (potentially)
never assigned, but in the case of %%FILL-BASHERS%% and *BACKEND-SBS*
nothing should use the unset elements, except that even so much as
examining the data in a REPL could in theory be undefined, so
in the interest of safety, assign all elements.
This commit is contained in:
Douglas Katzman 2021-05-18 19:44:15 -04:00
parent 65d8c5cfb8
commit 647077e62b
10 changed files with 18 additions and 10 deletions

View file

@ -25,7 +25,7 @@
(defmacro finalizer-max-id (store) `(elt ,store 2))
(defun make-finalizer-store (array-length)
(let* ((v (make-array (the index array-length)))
(let* ((v (make-array (the index array-length) :initial-element 0))
(ht (make-system-hash-table :test 'eq :weakness :key :synchronized nil
:finalizer t)))
;; The recycle bin has a dummy item in front so that the simple-vector

View file

@ -1141,7 +1141,7 @@ symbol-case giving up: case=((V U) (F))
;; every consequent is trivial.
(when (= maxprobes 1)
(block try-table-lookup
(let ((values (make-array (length bins)))
(let ((values (make-array (length bins) :initial-element 0))
(single-value) ; only if exactly one clause
(types nil))
(dolist (clause clauses)

View file

@ -603,7 +603,8 @@
do (setf pointer (cdr (rplaca pointer item)))))))
sequence)
(define-load-time-global %%fill-bashers%% (make-array (1+ sb-vm:widetag-mask)))
(define-load-time-global %%fill-bashers%% (make-array (1+ sb-vm:widetag-mask)
:initial-element 0))
#.`(progn
,@(loop for saetp across sb-vm:*specialized-array-element-type-properties*
for et = (sb-vm:saetp-specifier saetp)

View file

@ -131,7 +131,8 @@
(let* ((unicode-table
(make-array
(* 64 (1+ (aref **character-case-pages**
(1- (length **character-case-pages**)))))))
(1- (length **character-case-pages**)))))
:initial-element 0))
(table (make-array
(* 2 (length unicode-table))
:element-type '(unsigned-byte 32)))

View file

@ -852,7 +852,8 @@
;;; The compiler will never look at the toplevel value though.
(defvar *finite-sbs*
#-sb-xc-host
(make-array #.(count :non-packed *backend-sbs* :key #'sb-kind :test #'neq)))
(make-array #.(count :non-packed *backend-sbs* :key #'sb-kind :test #'neq)
:initial-element (make-unbound-marker)))
#-sb-xc-host
(progn
(declaim (type (simple-vector #.(length *finite-sbs*)) *finite-sbs*)

View file

@ -252,7 +252,8 @@
;;; space-efficient form, and return that packed form.
(defun pack-xref-data (xref-data)
(unless xref-data (return-from pack-xref-data))
(let* ((result (make-array 1 :adjustable t :fill-pointer 1))
(let* ((result (make-array 1 :adjustable t :fill-pointer 1
:initial-element 0))
(ensure-index (name->index result))
(entries '())
(max-index 0)
@ -287,7 +288,7 @@
(number-bits (integer-length max-number))
(encoder (index-and-number-encoder name-bits number-bits))
(vector (make-array 0 :element-type '(unsigned-byte 8)
:adjustable t :fill-pointer 0)))
:adjustable t :fill-pointer 0 :initial-element 0)))
(write-var-integer name-bits vector)
(write-var-integer number-bits vector)
(loop for (kind-number . kind-entries) in entries

View file

@ -11,6 +11,7 @@
(let* ((x (make-array (truncate #-sb-safepoint (* 0.2 (dynamic-space-size))
#+sb-safepoint (* 0.1 (dynamic-space-size))
sb-vm:n-word-bytes))))
(setf (elt x 0) t)
(elt x 0)))
(with-test (:name :bug-936304)

View file

@ -3100,7 +3100,7 @@
(setq x (make-array '(4 4)))
(adjust-array y '(3 5))
(array-dimension y 0)))
(((make-array '(4 4) :adjustable t)) 3)))
(((make-array '(4 4) :initial-element nil :adjustable t)) 3)))
(with-test (:name :with-timeout-code-deletion-note)
(checked-compile `(lambda ()

View file

@ -450,7 +450,8 @@
(with-test (:name (:print-frame-call :respect *debug-print-variable-alist*
*print-length* :bug-1261646))
(let* ((printed (print-backtrace-to-string/debug-print-variable-alist (make-array 200)))
(let* ((printed (print-backtrace-to-string/debug-print-variable-alist
(make-array 200 :initial-element 0)))
(call "(PRINT-BACKTRACE-TO-STRING/DEBUG-PRINT-VARIABLE-ALIST ")
(position (+ (search call printed) (length call))))
(assert (eql position (search "#(0 0 0 0 0 ...)" printed :start2 position)))))

View file

@ -551,7 +551,9 @@
;; lp#1333731
(with-test (:name (adjust-array :changes type-of))
(let ((a (make-array 10 :adjustable t)))
;; I think adjusting an array to enlarge it must read all the old data,
;; which would be undefined behavior if you hadn't initialized the array.
(let ((a (make-array 10 :adjustable t :initial-element 0)))
(assert (equal (type-of a) '(vector t 10)))
(adjust-array a 20)
(assert (equal (type-of a) '(vector t 20)))))