DEFSTRUCT: reading from slots without provided initforms
Via https://twitter.com/RainerJoswig/status/1484711125459550216
(eval-when (:compile-toplevel :load-toplevel :execute)
;;; Clause-info structures, which are put in the clause index.
(defstruct clause-info
function
keywords
req-keywords
doc-string
generator?)
;;; Driver-info structures, for information about driver variables--used by
;;; NEXT.
(defstruct driver-info
next-code
generator?
(used nil))
;;; Previous-info structures, used by the PREVIOUS mechanism.
(defstruct previous-info
var
save-info-list
code
(class :step))
(defstruct save-info
save-var
save-vars
iv-ref)
)
Reading from a slot for which no default value was provided before that value was set is undefined behavior, and Rainer notes that this bit him on Genera. For instance, MAKE-PREVIOUS-INFO
is called like (make-previous-info :var var :class default-class)
which means that the initial values of CODE
and SAVE-INFO-LIST
are undefined. Rainer likely ends up with attempts to read from these slots somewhere from within ITERATE, and that invokes UB.
A solution is to provide explicit initialization forms for these.