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

To reply to this bug, email your comments to 45816 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#45816; Package guile. (Tue, 12 Jan 2021 15:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to d4ryus <d4ryus <at> mailbox.org>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Tue, 12 Jan 2021 15:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: d4ryus <d4ryus <at> mailbox.org>
To: bug-guile <at> gnu.org
Subject: (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)]

Information forwarded to bug-guile <at> gnu.org:
bug#45816; Package guile. (Thu, 06 May 2021 10:47:01 GMT) Full text and rfc822 format available.

Message #8 received at 45816 <at> debbugs.gnu.org (full text, mbox):

From: d4ryus <d4ryus <at> mailbox.org>
To: 45816 <at> debbugs.gnu.org
Subject: (ice-9 suspendable-ports):get-bytevector-some! is broken
Date: Thu, 6 May 2021 12:46:34 +0200
Hi,

this was fixed by:

  commit f591ad28f1bcec67f17a123766f798d16bec5373
  Author: Andrew Whatson <whatson <at> gmail.com>
  Date:   Fri Jan 22 20:10:10 2021 +1000

    Fix suspendable implementation of 'get-bytevector-some!'

    * module/ice-9/suspendable-ports.scm (get-bytevector-some!): Fix
      incorrect arguments to bytevector-copy!

which was released with guile 3.0.6.


- d4ryus




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

Previous Next


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