slime/slime — pull request #155 by lmj (2014-04-26 14:15:34+00:00)
Title: Fix stale sldbs not being removed.

Two test cases follow. The first is

(defun test ()
(restart-case (error "No value.")
(input-value (value)
:report "Input a value."
:interactive (lambda ()
(format *query-io* "Enter value: ")
(finish-output *query-io*)
(multiple-value-list (eval (read *query-io*))))
value)))

After a value is entered, the `test` function completes correctly, but the sldb is still open. Attempting to interact with it results in various errors or hanging.

In the next test case, we try to remove sldbs by killing the corresponding threads.

#+quicklisp
(eval-when (:compile-toplevel :load-toplevel :execute)
(ql:quickload :bordeaux-threads))

(defun test ()
(let (threads)
(labels ((kill-others ()
(dolist (thread threads)
(unless (eq thread (bt:current-thread))
(bt:destroy-thread thread))))
(task ()
(restart-case (error "Some error.")
(kill-others ()
:report "Kill other threads."
(kill-others)))))
(setf threads (loop repeat 10
collect (bt:make-thread #'task))))))

After selecting the `kill-others` restart, some number of stale sldbs remain open.

Emacs 24.3.1. Confirmed on SBCL, CCL, Allegro, LispWorks.

Last unbroken state is 89528e796aca11a54243d0168b896caa1f9666ed.

It would seem that erroring CL threads more closely correspond to buffers than to windows. Replacing `(quit-window t)` with `(kill-buffer nil)` fixes the problem for me. Test results are the same as before.