GNU bug report logs - #45816
(ice-9 suspendable-ports):get-bytevector-some! is broken

Previous Next

Package: guile;

Reported by: d4ryus <d4ryus <at> mailbox.org>

Date: Tue, 12 Jan 2021 15:04:01 UTC

Severity: normal

Full log


View this message in rfc822 format

From: d4ryus <d4ryus <at> mailbox.org>
To: 45816 <at> debbugs.gnu.org
Subject: bug#45816: (ice-9 suspendable-ports):get-bytevector-some! is broken
Date: Tue, 12 Jan 2021 15:19:05 +0100
[Message part 1 (text/plain, inline)]
hi,

(ice-9 suspendable-ports):get-bytevector-some! calls bytevector-copy!
with transfer-size (which is a number) as third argument:

  ...
  (define (get-bytevector-some! port bv start count)
    (if (zero? count)
        0
        (call-with-values (lambda () (fill-input port 1 'binary))
          (lambda (buf cur buffered)
            (if (zero? buffered)
                (begin
                  (set-port-buffer-has-eof?! buf #f)
                  the-eof-object)
                (let ((transfer-size (min count buffered)))
                  (bytevector-copy! (port-buffer-bytevector buf) cur
                                    transfer-size start buffered)
                  (set-port-buffer-cur! buf (+ cur transfer-size))
                  transfer-size))))))
  ...

The third argument to bytevector-copy! must be the target bytevector,
from the doc:

  Scheme Procedure: bytevector-copy! source source-start target target-start len

    Copy len bytes from source into target, starting reading from
    source-start (a positive index within source) and start writing at
    target-start. It is permitted for the source and target regions to
    overlap.

I think the correct call is:

  (bytevector-copy! (port-buffer-bytevector buf) cur
                    bv start transfer-size)


A potentional fix is attached.

If you need any additional information, please let me know.


-  d4ryus
[suspendable-get-bytevector-some-fix.patch (text/plain, attachment)]

This bug report was last modified 4 years and 40 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.