unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#45816: (ice-9 suspendable-ports):get-bytevector-some! is broken
@ 2021-01-12 14:19 d4ryus via Bug reports for GUILE, GNU's Ubiquitous Extension Language
  2021-05-06 10:46 ` d4ryus via Bug reports for GUILE, GNU's Ubiquitous Extension Language
  0 siblings, 1 reply; 2+ messages in thread
From: d4ryus via Bug reports for GUILE, GNU's Ubiquitous Extension Language @ 2021-01-12 14:19 UTC (permalink / raw)
  To: 45816

[-- Attachment #1: Type: text/plain, Size: 1400 bytes --]

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

[-- Attachment #2: suspendable-get-bytevector-some-fix.patch --]
[-- Type: text/plain, Size: 609 bytes --]

diff --git a/module/ice-9/suspendable-ports.scm b/module/ice-9/suspendable-ports.scm
index f5f005cca..a823f1d37 100644
--- a/module/ice-9/suspendable-ports.scm
+++ b/module/ice-9/suspendable-ports.scm
@@ -338,7 +338,7 @@
                 the-eof-object)
               (let ((transfer-size (min count buffered)))
                 (bytevector-copy! (port-buffer-bytevector buf) cur
-                                  transfer-size start buffered)
+                                  bv start transfer-size)
                 (set-port-buffer-cur! buf (+ cur transfer-size))
                 transfer-size))))))


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#45816: (ice-9 suspendable-ports):get-bytevector-some! is broken
  2021-01-12 14:19 bug#45816: (ice-9 suspendable-ports):get-bytevector-some! is broken d4ryus via Bug reports for GUILE, GNU's Ubiquitous Extension Language
@ 2021-05-06 10:46 ` d4ryus via Bug reports for GUILE, GNU's Ubiquitous Extension Language
  0 siblings, 0 replies; 2+ messages in thread
From: d4ryus via Bug reports for GUILE, GNU's Ubiquitous Extension Language @ 2021-05-06 10:46 UTC (permalink / raw)
  To: 45816

Hi,

this was fixed by:

  commit f591ad28f1bcec67f17a123766f798d16bec5373
  Author: Andrew Whatson <whatson@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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-06 10:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12 14:19 bug#45816: (ice-9 suspendable-ports):get-bytevector-some! is broken d4ryus via Bug reports for GUILE, GNU's Ubiquitous Extension Language
2021-05-06 10:46 ` d4ryus via Bug reports for GUILE, GNU's Ubiquitous Extension Language

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).