* 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
0 siblings, 0 replies; only message 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 [flat|nested] only message in thread
only message in thread, other threads:[~2021-01-12 14:19 UTC | newest]
Thread overview: (only message) (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
unofficial mirror of bug-guile@gnu.org
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://yhetil.org/guile-bugs/0 guile-bugs/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 guile-bugs guile-bugs/ https://yhetil.org/guile-bugs \
bug-guile@gnu.org
public-inbox-index guile-bugs
Example config snippet for mirrors.
Newsgroups are available over NNTP:
nntp://news.yhetil.org/yhetil.lisp.guile.bugs
nntp://news.gmane.io/gmane.lisp.guile.bugs
AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git