[slime-devel] Followup on dangerous bug

Bradford W. Miller Bradford_W_Miller at Raytheon.com
Mon Feb 6 16:49:22 UTC 2006


Last week I reported on a problem where a buffer in the slime-typeout  
window would be overwritten if the *SLIME-Typeout* buffer is killed  
by the user.

A suggested fix follows:

The code calls the function slime-typeout-active-p in order to assure  
the window is open. However, this call does NOT insure that the  
correct buffer is exposed in that window. The saved window is in the  
variable "slime-typeout-window", but this will reflect any exposed  
buffer in that window, not "*SLIME-Typeout*".

I have modified the slime-typeout-active-p function as follows, to  
make sure that the window has the correct buffer in the foreground  
before the caller does the write. (There is still the potential for a  
collision if the buffer is switched between calling this function and  
writing to it, however, I'm unfamiliar with mechanisms for locking  
frames in emacs to prevent that). Instead, perhaps for full safety,  
the call (window-buffer slime-typeout-window) in slime-typeout- 
message should be (get-buffer-create "*SLIME-Typeout*") instead. That  
way the write always occurs to the correct buffer, and not the one  
that happens to be exposed.

At least on my local copy, these functions works normally, and  
killing *SLIME-Typeout* causes it to be restored before, e.g.,  
showing the arglist for the function at prompt while in the slime REPL.

These patches fix two problems: 1) that the use of the typeout window  
may go to the wrong buffer if the wrong buffer happens to be exposed  
and 2) that the *SLIME-Typeout* buffer is not exposed in the window  
created for that express purpose.

Allow me to suggest these patchs for inclusion in the CVS.

(defun slime-typeout-active-p () ;; modified 2/6/06 BWM
   (cond
    ((and slime-typeout-window
          (window-live-p slime-typeout-window))
     (save-selected-window
       (select-window slime-typeout-window)
       (switch-to-buffer "*SLIME-Typeout*"))
     t) ; return true -it's active and ready
    (t
     nil)))

(defun slime-typeout-message (format-string &rest format-args)
   (assert (slime-typeout-active-p))
   (with-current-buffer (get-buffer-create "*SLIME-Typeout*") ;;  
modified 2/6/06 BWM
     (erase-buffer)
     (insert (apply #'format format-string format-args))))





More information about the slime-devel mailing list