Windows: Can't terminate-thread that's in the middle of a socket call
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
New
|
Undecided
|
Unassigned |
Bug Description
Here's some code that creates an immortal thread in Windows:
(defpackage immortal-thread
(:use :common-lisp :sb-thread :sb-bsd-sockets))
(in-package :immortal-thread)
(make-thread
(lambda ()
(let* ((listen (make-instance 'sb-bsd-
(accept nil)
(connect (make-instance 'sb-bsd-
:type :stream :protocol :tcp)))
(socket-bind listen #(127 0 0 1) 12121)
(socket-listen listen 5)
(setf accept (socket-accept listen)))))
The thread ends up as the CAR of (list-all-threads), so this should terminate it:
(terminate-
Doing (list-all-threads) after that shows that the thread is still there.
Also, (thread-alive-p (car (list-all-
The thread is not immortal on Linux. This is a Windows-specific problem.
I've also confirmed that this does not happen if the thread is in a busy-wait loop such as
(loop do (progn nil)).
*FEATURES* contains:
(CHIPZ-
CFFI-FEATURES:
CFFI-SYS:
:ASDF3 :ASDF2 :ASDF :OS-WINDOWS :NON-BASE-
:ALIEN-CALLBACKS :ANSI-CL :ASH-RIGHT-VOPS :C-STACK-
:COMMON-LISP :COMPARE-
:IEEE-
:MEMORY-
:OS-PROVIDES-
:RAW-INSTANCE-
:SB-PACKAGE-LOCKS :SB-QSHOW :SB-SAFEPOINT :SB-SAFEPOINT-
:SB-SOURCE-
:SBCL :STACK-
:STACK-
:STACK-
:UNWIND-
More info: If you make a socket call from SLIME and it doesn't complete, you can't break out of it with C-c C-c like you'd normally be able to. SBCL cannot receive the interrupt from EMACS until the socket call completes.