[slime-devel] Bug report: error in process filter: destructure-case failed

When I evaluate something in REPL which produces a lot of rapid output, sometimes I get a message "destructure-case failed: (:WRITE-STRING ... part of the output ...)" in the message area, and the corresponding output is never added to the REPL buffer. This is happens especially often when I use (trace "ENTIRE-PACKAGE") in order to debug something. I can fix the problem by editing slime.el and adding a duplicate case in the slime-dispatch-event function for :WRITE-STRING (in upper case) being the same as :write-string, but thats just fixing the symptom and the underlaying buy in Slime remains. Here is a test case that I can reproduce 100% Emacs: 22.0.51.7-multi-tty (also happened on 21.3) Slime: latest CVS Lisp: SBCL 0.9.13 x86-64 OS: SuSe 10 64bit, 2.6.15-rc6-2-smp kernel Hardware: Dual core Opteron CL-USER> (require 'cl-ppcre) NIL CL-USER> (trace "CL-PPCRE") ... bunch of output listing all functions in CL-PPCRE ... Now just do the following several times: CL-USER> (cl-ppcre::parse-string "a*b+") ... TRACE output here ... You should see the destructure-case failed messages. Note that sometimes its every other invocation, sometimes you have to do it 10 times to get it. Below is a paste from my *Messages* buffer ---------------------- *Messages* ---------------------- error in process filter: destructure-case failed: (:WRITE-STRING " 4: (CL-PPCRE::GREEDY-QUANT #S(CL-PPCRE::LEXER :STR \"a*b+\" :LEN 4 :REG 0 :POS 0 :LAST-POS NIL)) ") error in process filter: slime-dispatch-event: destructure-case failed: (:WRITE-STRING " 6: CL-PPCRE::NEXT-CHAR returned #\\+ ") error in process filter: destructure-case failed: (:WRITE-STRING " 6: CL-PPCRE::NEXT-CHAR returned #\\+ ") error in process filter: destructure-case failed: (:WRITE-STRING " 6: CL-PPCRE::NEXT-CHAR returned #\\+ ") --------------------------------------------------------- Regards, Max

* Max Mikhanosha [2006-07-14 00:44+0200] writes:
Here is a test case that I can reproduce 100%
Emacs: 22.0.51.7-multi-tty (also happened on 21.3) Slime: latest CVS Lisp: SBCL 0.9.13 x86-64 OS: SuSe 10 64bit, 2.6.15-rc6-2-smp kernel Hardware: Dual core Opteron
I can't reproduce the error on my machine. But I think that we are very careful to bind *print-case* properly: (defun prin1-to-string-for-emacs (object) (with-standard-io-syntax (let ((*print-case* :downcase) (*print-readably* nil) (*print-pretty* nil) (*package* *swank-io-package*)) (prin1-to-string object)))) and I can't quite see why :write-string is ever printed in upper case. My suspicion is that SBCL's printer is not thread-safe. In particular, the use of sb-impl::*previous-case* looks like it could lead the kind of bugs that you see. Helmut.

At Fri, 14 Jul 2006 15:36:07 +0200, Helmut Eller wrote:
My suspicion is that SBCL's printer is not thread-safe. In particular, the use of sb-impl::*previous-case* looks like it could lead the kind of bugs that you see.
Yup SBCL bug, there is a bunch of special variables internal to code/print.lisp, which are never bound when threads are started and as such are shared between all threads.. Ie *internal-symbol-output-fun* is global and is clobbered by every thread when *print-case* is changed, so it always uses the value that was set by the last thread which changed *print-case* to a different value. Now that I've figured this out, I remember giving up playing with kpax and portable-aserve, because of too many bugs where the case was bad (it uses the :keyword for HTTP headers, and wrong case was popping up all over the place). Now I think there is nothing wrong with portable-aserve and kpax, but instead I was hitting the same bug. --- SBCL test that (may only be failing on SMP hardware) --- CL-USER> (let ((iterations 100000)) (sb-thread:make-thread (lambda () (let ((*print-case* :downcase)) (dotimes (i iterations) (assert (string= (with-output-to-string (s) (prin1 'FOO s)) "foo")))w))) (sb-thread:make-thread (lambda () (let ((*print-case* :upcase)) (dotimes (i iterations) (assert (string= (with-output-to-string (s) (prin1 'FOO s)) "FOO")))))) ) --- end --- Regards, Max
participants (2)
-
Helmut Eller
-
Max Mikhanosha