with-input-from-string incorrectly signals closed-stream-error

Bug #1333327 reported by Jared Davis
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Invalid
Undecided
Unassigned

Bug Description

Below is a test script that, I think:
  - Behaves "correctly" on SBCL 1.0.46 and current CCL
  - Behave strangely on SBCL 1.1.14, perhaps a bug.

Thanks!

$ cat tmp.lsp # here is the test script

   (defun read-string-fn (str)
     (handler-case
       (let ((acc nil))
         (with-input-from-string
           (stream str)
           (loop do
                 (let* ((eof-marker (cons nil nil))
                        (elem (read stream nil eof-marker)))
                   (if (eq elem eof-marker)
                       (loop-finish)
                     (push elem acc)))))
         (setq acc (nreverse acc))
         (values :OK acc))
       (error (condition)
              (return-from read-string-fn
                (values :ERROR (format nil "~A" condition))))
       (storage-condition (condition)
                          (return-from read-string-fn
                            (values :STORAGE (format nil "~A" condition))))))

   ;; Test: try to read #\wtf, which of course is silly and should cause an
   ;; error. But, I think, the error handler above should catch this error.
   (read-string-fn "#\wtf")

$ sbcl-1.0.46 < tmp.lsp # works as expected, the error is caught

   This is SBCL 1.0.46, an implementation of ANSI Common Lisp.
   More information about SBCL is available at <http://www.sbcl.org/>.

   SBCL is free software, provided as is, with absolutely no warranty.
   It is mostly in the public domain; some portions are provided under
   BSD-style licenses. See the CREDITS and COPYING files in the
   distribution for more information.
   *
   READ-STRING-FN
   *
   :ERROR
   "SB-INT:SIMPLE-READER-ERROR on #<SB-IMPL::STRING-INPUT-STREAM {1002B072B1}>:
     no dispatch function defined for #\\W"
   *

$ ccl < tmp.lsp # works as expected, the error is caught

   Welcome to Clozure Common Lisp Version 1.10-dev-r16049M-trunk (LinuxX8664)!
   ? READ-STRING-FN
   ? :ERROR
   "Reader error on #<STRING-INPUT-STREAM :CLOSED #x3020004B3E4D>:
   Undefined character #\\W in a #\\# dispatch macro."
   ?

$ sbcl-1.1.14 < tmp.lsp # bug? causes and does not catch a stream closing error

   This is SBCL 1.1.14, an implementation of ANSI Common Lisp.
   More information about SBCL is available at <http://www.sbcl.org/>.

   SBCL is free software, provided as is, with absolutely no warranty.
   It is mostly in the public domain; some portions are provided under
   BSD-style licenses. See the CREDITS and COPYING files in the
   distribution for more information.
   *
   READ-STRING-FN
   *
   debugger invoked on a SB-INT:CLOSED-STREAM-ERROR in thread
   #<THREAD "main thread" RUNNING {1002AA3B73}>:
     #<SB-IMPL::STRING-INPUT-STREAM {1002C74A83}> is closed

   Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

   restarts (invokable by number or by possibly-abbreviated name):
     0: [ABORT] Exit debugger, returning to top level.

   (SB-KERNEL:CLOSED-FLAME #<SB-IMPL::STRING-INPUT-STREAM {1002C74A83}>)

Revision history for this message
Stas Boukarev (stassats) wrote :

You are using 1.1.14, which was released last year. There's no such problem anymore. Please, test your bug on the current release (or preferably on the current git head) before reporting it.

Changed in sbcl:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.