bugMIT/GNU Scheme - Bugs: bug #66166, read-char sometimes returns...

 
 

bug #66166: read-char sometimes returns eof-object, sometimes returns #f

Submitter:  Taylor R. Campbell <riastradh>
Submitted:  Wed 04 Sep 2024 12:49:55 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  None Privacy:  Public
Assigned to:  None Originator Name: 
Open/Closed:  Open
Keywords: 
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 04 Sep 2024 12:49:55 PM UTC, original submission:  

I have been regularly seeing crashes in IMAIL inside read-delimited-string arising from attempt to evaluate (char-code #f) inside %make-string-builder -> append-char!.

It's hard to trace where this #f came from because there are so many layers of untyped abstractions, but I suspect the generic I/O's input buffer normalizer returned #f when the callers all expected eof-object.  This presumably happens because the normalizer calls into peek-u8, which is:

(define (peek-u8 #!optional port)
  (let ((ib (check-input-port port 'peek-u8)))
    (let loop ((state (input-buffer-state ib 'peek-u8)))
      (case state
        ((filled) (bytevector-u8-ref (buffer-bytes ib) (buffer-start ib)))
        ((unfilled) (loop (fill-input-buffer! ib)))
        ((eof) (eof-object))
        (else #f)))))

Why is this introducing #f here?  I don't see it as an allowed return value in the R7RS definition of peek-u8: https://small.r7rs.org/attachment/r7rs.pdf#page=58

Taylor R. Campbell <riastradh>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by riastradh (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-5884.
    Corresponding source code