[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug (and fix for same) in ALL-STD-CLASS-WRITERS-MISS



There is an bug in ALL-STD-CLASS-WRITERS-MISS (dcode.lisp) that can
cause some weird behavior in rare circumstances.  The following
typescript illustrates a simple case that trips up the bug.  The fix
is to add NEW-VALUE as an argument to the call LOOKUP-METHOD-1 inside
ALL-STD-CLASS-WRITERS-MISS as illustrated below the typescript.

;;;-----Example
<cl> pcl::*PCL-SYSTEM-DATE*

"8/28/88 (beta rev 1) AAAI PCL "
<cl> (use-package :pcl)

T
<cl> (defclass a ()((a :accessor b)))

NIL
<cl> (defclass b ()((b :accessor b)))

NIL
<cl> (setq a (make-instance 'a))

#<A 25172201>
<cl> (setf (b a) 45)

Error: When attempting to set the slot's value to 45 (setf of slot-value),
the slot B is missing from the object #<A 25172201>.
[1] <cl> 

;;;----  Fix
;; from dcode.lisp

(defun all-std-class-writers-miss
       (new-value arg wrapper .cache. cache-size offset generic-function)
  (setq offset (cache-key-from-wrappers-2 cache-size arg))
  (let ((class (wrapper-class wrapper))
	(method (lookup-method-1 generic-function new-value arg)))
;;;
;;; FIX                                           ---------  
;;;
    (if (null method)
	(no-applicable-method generic-function new-value arg)
	(let* ((slot-name (reader/writer-method-slot-name method))
	       (slot-pos (all-std-class-readers-miss-1 class
						       wrapper
						       slot-name)))
	  (if (not (null slot-pos))
	      (progn 
		(without-interrupts
		  (setf (r/w-cache-key) wrapper)
		  (setf (r/w-cache-val) slot-pos))
		(setf (%svref (iwmc-class-static-slots arg) slot-pos)
		      new-value))
	      (setf (slot-value-using-class class arg slot-name)
		    new-value))))))
  


-- Frank

---------

Frank Halasz          
MCC Software Technology
9390 Research Blvd
Austin TX 78759.
[512]338-3648 

halasz@MCC.COM
or {harvard,ihnp4,nike,seismo}!ut-sally!im4u!milano!halasz