Opened 12 years ago

Closed 12 years ago

#645 closed defect (fixed)

stream-read-ivector fails for non-byte ivectors

Reported by: a_gavrilov Owned by: gb
Priority: normal Milestone:
Component: Runtime (threads, GC) Version: 1.4
Keywords: binary IO Cc:


This function is documented as accepting any ivector. However the actual behavior is quite different:

? (defvar arr (make-array 5 :element-type 'single-float))
? (with-open-file (s "/dev/zero" :direction :input :element-type '(unsigned-byte 8))
    (stream-read-ivector s arr 0 20))
> Error: 0 doesn't match array element type of #<VECTOR 5 type SINGLE-FLOAT, simple>.
> While executing: CCL::%IOBLOCK-BINARY-IN-IVECT, in process listener(1).

This is fixed by the following change, but it is obviously a very ugly hack that depends on the implementation details of the read function:

--- l1-streams.lisp     (revision 13365)                           
+++ l1-streams.lisp     (working copy)                             
@@ -2471,10 +2471,10 @@                                            
     (let* ((b (funcall rbf ioblock)))                             
       (if (eq b :eof)                                             
        (return (- i start)))                                      
-      (setf (uvref vector i) b)                                   
-      (incf i)                                                    
-      (decf need)                                                 
-      (let* ((idx (io-buffer-idx in))                             
+   ;   (setf (uvref vector i) b)                                  
+   ;   (incf i)                                                   
+   ;   (decf need)                                                
+      (let* ((idx (1- (io-buffer-idx in)))                        
             (count (io-buffer-count in))                          
             (avail (- count idx)))                                
        (declare (fixnum idx count avail))

Change History (1)

comment:1 Changed 12 years ago by gb

  • Resolution set to fixed
  • Status changed from new to closed

(In [13366]) In %IOBLOCK-BINARY-IN-IVECT, use (SETF AREF), not (SETF UVREF). Fixes ticket:645.

Todo: consider open-coding (SETF UVREF) when vector type is declared.

Note: See TracTickets for help on using tickets.