Helu
I wonder if others have seen this problem: I see it once in a while and thought I'd ask here first.
Lisp breaks off the connection with the following messages
At the slime REPL:
;; swank:close-connection: There's junk in this string: "ces (q".
In *slime-events*
(:emacs-rex (swank:arglist-for-echo-area '("mb") :arg-indices '(2) :print-right-margin 80 :print-lines nil) "COMMON-LISP-USER" :repl-thread 2589) (:emacs-rex (swank:listener-eval "(mb 1240368 2183207)\n") "COMMON-LISP-USER" :repl-thread 2590) (:write-string ";; swank:close-connection: There's junk in this string: "ces (q".\n")
And at the CMUCL REPL (debugger):
Source: (ERROR "~S is closed." STREAM)q
Help! 12 nested errors. KERNEL:*MAXIMUM-ERROR-DEPTH* exceeded.
Debug (type H for help)
(LISP::CLOSED-FLAME #<Stream for descriptor 9>)
Then, at the CMUCL repl, I can keep hitting `q' and get the same error message repeated a number of times until enough input is read, and either I pop back to the top level prompt (if I'm lucky), or I get dropped into ldb and lisp exits, if unlucky. If I do get back a prompt, A GC will show a number of
** Closed the Terminal ** Closed the Terminal ** Closed the Terminal ** Closed the Terminal
lines.
Have other people seen this sort of problem?
I'd like to track down the source of the problem, so any suggestions are welcome.
-- Madhu
PS: Marco, did you get my earlier report and patch on the inspector being broken from the last commits?
* Madhu m3wsxcz2y8.fsf@robolove.meer.net : * http://permalink.gmane.org/gmane.lisp.slime.devel/6368 | I wonder if others have seen this problem: I see it once in a while and | thought I'd ask here first.
I am able to get a repeatable test case with the latest CMUCL snapshot. and latest SLIME from CVS: It is as simple as
M-x slime M-x slime-disconnect
With these settings
(cl:setq SWANK:*USE-DEDICATED-OUTPUT-STREAM* t SWANK:*COMMUNICATION-STYLE* :sigio SWANK::*GLOBALLY-REDIRECT-IO* NIL nil)
With :fd-handler communication style and dedicated output stream CMUCL is confused into going into an infinite loop writing to the closed stream.
The combination of no dedicated output stream and :sigio does not trigger the ldb. (But I get dropped intermittently to ldb)
I noticed this changelog entry:
* 2004-11-15 Helmut Eller heller@common-lisp.net
* swank-cmucl.lisp (emacs-connected): Install GC hooks to display GC messages in the echo area. (sos/misc :flush-output): There seem to be funny signal safety issues if the dedicated output stream is not used. So, lets first reset the buffer index before sending the buffer to the underlying stream.
And the backtraces I noticed were along the lines of
54: COMMON-LISP::ERROR 55: LISP::CLOSED-FLAME 56: COMMON-LISP::WRITE-CHAR 57: FORMAT::FORMAT-WRITE-FIELD 58: FORMAT::FORMAT-PRINT-INTEGER 59: FORMAT::X-FORMAT-DIRECTIVE-INTERPRETER 60: FORMAT::INTERPRET-DIRECTIVE-LIST 61: FORMAT::%FORMAT 62: COMMON-LISP::FORMAT 63: SWANK::ENCODE-MESSAGE 64: SWANK::SLDB-LOOP 65: SWANK::CALL-WITH-BINDINGS 66: "DEFIMPLEMENTATION CALL-WITH-DEBUGGING-ENVIRONMENT" 67: SWANK::DEBUG-IN-EMACS 68: COMMON-LISP::INVOKE-DEBUGGER 69: COMMON-LISP::ERROR 70: LISP::CLOSED-FLAME 71: COMMON-LISP::WRITE-CHAR 72: FORMAT::FORMAT-WRITE-FIELD 73: FORMAT::FORMAT-PRINT-INTEGER 74: FORMAT::X-FORMAT-DIRECTIVE-INTERPRETER 75: FORMAT::INTERPRET-DIRECTIVE-LIST 76: FORMAT::%FORMAT 77: COMMON-LISP::FORMAT 78: SWANK::ENCODE-MESSAGE 79: "DEFUN MAKE-OUTPUT-FUNCTION" 80: "DEFINTERFACE CALL-WITH-DEBUGGER-HOOK" 81: SWANK::CALL-WITH-REDIRECTED-IO 82: SWANK::CALL-WITH-CONNECTION 83: (COMMON-LISP::FLET G1 SWANK-BACKEND::SOS/MISC) 84: SWANK-BACKEND::SOS/MISC 85: COMMON-LISP::FINISH-OUTPUT 86: (COMMON-LISP::FLET G0 SWANK-BACKEND::SOS/MISC-FORCE-OUTPUT) 87: SWANK-BACKEND::SOS/MISC-FORCE-OUTPUT 88: SWANK-BACKEND::SOS/MISC
Indicating that the swank is trying to report the closed file error message on the closed stream. [?]
I had asked questions on REDIRECT-IO before and I can guess at some problems with the current protocol, but I'll wait for a response from the original implementors, if they could identify and suggest what the problem is, or at least document the known issues.
Thanks -- Madhu
Re: http://permalink.gmane.org/gmane.lisp.slime.devel/6368
I have tracked down the problem: When the stream to emacs is closed, SWANK::DECODE-MESSAGE catches an end-of-file and throws a SWANK:STREAM-ERROR. SWANK::SIMPLE-SERVE-EVENTS catches this (via SWANK::WITH-READER-ERROR-HANDLER) Now there are several code paths but all result in recursive errors which result from writing about errors on writing to a closed stream to a closed stream.
- either by invoking the debugger (debugger-hook is slime debugger) - swank::close-connection writes to the closed-stream by calling finish-output
There are several ways to fix this problem. At the least the finish-output calls should be enclosed in ignore-error forms. Ideally the current headache inducing stream design would be redesigned with sanity.
Which patch would you prefer?
-- Madhu
Re: http://permalink.gmane.org/gmane.lisp.slime.devel/6378
FWIW Heres an ugly patch which fixes the recursive writing to closed stream bug