unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#17466: unexpected bytevector contents with get-bytevector-n
@ 2014-05-11 11:00 J Kalbhenn
  2014-05-28 15:26 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: J Kalbhenn @ 2014-05-11 11:00 UTC (permalink / raw)
  To: 17466

concerning the following code example
--
(import (rnrs io ports) (ice-9 pretty-print))
(define (problem-part port) (pretty-print (get-bytevector-n port 4096)))

(let loop ((count 100))
  (if (> count 0)
    (begin (call-with-input-string "22222222222222222222" problem-part)
(loop (- count 1)))))
__

when i run it i get output with portions like this
--
#vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
#vu8(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
#vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
#vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
#vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
#vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
#vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
#vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
#vu8(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
#vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
#vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
#vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
#vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
#vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
#vu8(50 50 50 50 50 50 50 50 16 224 240 0 0 0 0 0 50 50 50 50)
#vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
--

and i would expect the bytevector to always be the same.

this first occurred to me in a more complicated scenario where:
  - the input port is a file-port
  - pretty-print was used at first and then display instead, but the
problem persisted with a much lower frequency

system info
  guile 2.0.11
  linux 3.14.2-1-ARCH x86_64





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

* bug#17466: unexpected bytevector contents with get-bytevector-n
  2014-05-11 11:00 bug#17466: unexpected bytevector contents with get-bytevector-n J Kalbhenn
@ 2014-05-28 15:26 ` Ludovic Courtès
  2014-05-28 17:32   ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2014-05-28 15:26 UTC (permalink / raw)
  To: J Kalbhenn; +Cc: 17466

Hello,

J Kalbhenn <jkal@posteo.eu> skribis:

> (import (rnrs io ports) (ice-9 pretty-print))
> (define (problem-part port) (pretty-print (get-bytevector-n port 4096)))
>
> (let loop ((count 100))
>   (if (> count 0)
>     (begin (call-with-input-string "22222222222222222222" problem-part)
> (loop (- count 1)))))
> __
>
> when i run it i get output with portions like this
> --
> #vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
> #vu8(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
> #vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
> #vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
> #vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
> #vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
> #vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
> #vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
> #vu8(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
> #vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
> #vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
> #vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
> #vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
> #vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
> #vu8(50 50 50 50 50 50 50 50 16 224 240 0 0 0 0 0 50 50 50 50)
> #vu8(50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50)
> --
>
> and i would expect the bytevector to always be the same.

Indeed.  I’ve been experiencing that in a more complex scenario too:
<http://bugs.gnu.org/17591>.

The guts of the problem seems to be GC_REALLOC.  I’m debugging it now
and your reduced test case will be helpful.

Ludo’.





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

* bug#17466: unexpected bytevector contents with get-bytevector-n
  2014-05-28 15:26 ` Ludovic Courtès
@ 2014-05-28 17:32   ` Ludovic Courtès
  0 siblings, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2014-05-28 17:32 UTC (permalink / raw)
  To: J Kalbhenn; +Cc: 17466-done

This is fixed by commit 1baa215, which will be in Guile 2.0.12.

It turns out that when shrinking a bytevector, as happens before
‘get-bytevector-n’ returns, the pointer to the bytevector’s contents
would not be left pointing to the old bytevector.  When that old
bytevector was eventually reclaimed, anything could happen.

Thanks!

Ludo’.





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

end of thread, other threads:[~2014-05-28 17:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-11 11:00 bug#17466: unexpected bytevector contents with get-bytevector-n J Kalbhenn
2014-05-28 15:26 ` Ludovic Courtès
2014-05-28 17:32   ` Ludovic Courtès

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).