close Warning: Can't synchronize with repository "(default)" ("(default)" is not readable or not a Git repository.). Look in the Trac log for more information.

Opened 10 years ago

Closed 10 years ago

#105 closed defect (fixed)

error-handling bug

Reported by: Raymond Toy Owned by: somebody
Priority: major Milestone:
Component: Core Version: 2014-06
Keywords: Cc:

Description

From an email on cmucl-help from Matt Kaufmann on 2014/07/26.

It appears to be the same bug as this SBCL bug (now fixed for SBCL):

https://bugs.launchpad.net/sbcl/+bug/1333327

Here is a log illustrating the bug in the CMUCL versions mentioned above. The expected behavior is shown later below (using SBCL 1.2.1).

.......... CMUCL 20e and also 2014-06 snapshot: ..........

* (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))))))

READ-STRING-FN
* (read-string-fn "#\wtf")


Error in function LISP::CLOSED-FLAME:  #<String-Input Stream> is closed.
   [Condition of type SIMPLE-ERROR]

Restarts:
  0: [ABORT] Return to Top-Level.

Debug  (type H for help)

(LISP::CLOSED-FLAME #<String-Input Stream>)
Source: Error finding source: 
Error in function DEBUG::GET-FILE-TOP-LEVEL-FORM:  Source file no longer exists:
  target:code/stream.lisp.
0] 

..........

Here is the analogous log after defining the function above in SBCL 1.2.1, which I believe is as expected.

.......... SBCL 1.2.1 ..........

* (read-string-fn "#\wtf")

:ERROR
"no dispatch function defined for #\\W

  Stream: #<SB-IMPL::STRING-INPUT-STREAM {1002E27C03}>"
* 

Change History (2)

comment:1 Changed 10 years ago by Raymond Toy

comment:2 Changed 10 years ago by toy.raymond@…

Resolution: fixed
Status: newclosed

commit c0052f5544d27980c74d5a17cd55dc2069085602 Author: Raymond Toy <toy.raymond@…> Date: Sat Aug 9 12:53:57 2014 -0700

Fix ticket:105 by not flaming out on a closed stream.

  • code/reader.lisp:
    • The READER-ERROR condition tries to be helpful and print out the position of where the error occurred using FILE-POSITION. But FILE-POSITION flames out when the stream is closed, so check for a closed stream before calling FILE-POSITION

  • tests/trac.lisp:
    • Add test from the bug report.

  • general-info/release-20f.txt:
    • Update.
Note: See TracTickets for help on using tickets.