[slime-devel] Connection to Emacs lost. condition: junk in string
Helmut Eller
heller at common-lisp.net
Sun Jun 28 06:19:17 UTC 2009
* Kelly McDonald [2009-06-27 12:50+0200] writes:
> Helmut,
> Thanks for your reply.
> I believe what is happening is that read-sequence is running out of
> bytes to read from the socket, resulting in a top-level error, causing
> it to go back to process-requests
> which tries to decode-event on a socket that has a partially read
> packet queued up.
>
> I'm guessing that there is something that needs to be done to turn the
> socket into a somewhat friendlier stream in swank-sbcl/socket-fd so
> that you don't get the toplevel error when
> read-sequence out-runs the socket. - but that is just a guess.
>
> any pointers would be welcome!
Judging from your backtrace and assuming you have *communication-style*
set to :fd-handler, it looks indeed like read-sequence is running out of
bytes and then calls sb-sys:wait-until-fd-usable and then serve-event
which recursively calls Swank's fd-handler.
I think we have no other choice than to prevent our fd-handlers from
be called recursively. Can you reproduce the problem and try if
it goes away with the following modification in swank-sbcl.lisp?
(defimplementation add-fd-handler (socket fn)
(declare (type function fn))
(let ((fd (socket-fd socket))
(handler nil))
(labels ((add ()
(setq handler (sb-sys:add-fd-handler fd :input #'run)))
(run (fd)
(sb-sys:remove-fd-handler handler) ; prevent recursion
(unwind-protect
(funcall fn)
(when (sb-unix:unix-fstat fd) ; still open?
(add)))))
(add))))
Helmut.
More information about the slime-devel
mailing list