unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#15370: weirdness w/ uniform-vector-read! compat
@ 2013-09-13 15:49 Thien-Thi Nguyen
  2013-10-20  8:59 ` Ian Price
  0 siblings, 1 reply; 5+ messages in thread
From: Thien-Thi Nguyen @ 2013-09-13 15:49 UTC (permalink / raw)
  To: 15370


[-- Attachment #1.1: Type: text/plain, Size: 223 bytes --]

Proc ‘uniform-vector-read!’ is deprecated (ugh), and its implementation
rebased onto ‘(rnrs io ports) get-bytevector-n!’.  Unfortunately, there
seems to be a glitch in the arg shuffling.  Here is /tmp/foo.scm:


[-- Attachment #1.2: foo.scm --]
[-- Type: application/x-scheme, Size: 507 bytes --]

[-- Attachment #1.3: Type: text/plain, Size: 149 bytes --]


and here is a series of invocations that demonstrate the discrepency
between ‘get-bytevector-n!’ (ok) and ‘uniform-vector-read!’ (ko):


[-- Attachment #1.4: badness --]
[-- Type: text/plain, Size: 1424 bytes --]

set -x ; guile --version ; guile -s foo.scm ; guile -s foo.scm ok ; guile -s foo.scm ko
+ guile --version
guile (GNU Guile) 2.0.9
Copyright (C) 2013 Free Software Foundation, Inc.

License LGPLv3+: GNU LGPL 3 or later <http://gnu.org/licenses/lgpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
+ guile -s foo.scm
uve: #s16(0) (2)
uve: #s16(0)
+ guile -s foo.scm ok
uve: #s16(0) (2)
uve: #s16(10794)
+ guile -s foo.scm ko
uve: #s16(0) (2)
`uniform-vector-read!' is deprecated. Use `get-bytevector-n!' from
`(rnrs io ports)' instead.
Backtrace:
In ice-9/boot-9.scm:
 157: 11 [catch #t #<catch-closure 8347f30> ...]
In unknown file:
   ?: 10 [apply-smob/1 #<catch-closure 8347f30>]
In ice-9/boot-9.scm:
  63: 9 [call-with-prompt prompt0 ...]
In ice-9/eval.scm:
 432: 8 [eval # #]
In ice-9/boot-9.scm:
2320: 7 [save-module-excursion #<procedure 8275ea0 at ice-9/boot-9.scm:3961:3 ()>]
3968: 6 [#<procedure 8275ea0 at ice-9/boot-9.scm:3961:3 ()>]
1645: 5 [%start-stack load-stack ...]
1650: 4 [#<procedure 83489c0 ()>]
In unknown file:
   ?: 3 [primitive-load "/tmp/foo.scm"]
   ?: 2 [call-with-input-string "****" ...]
In ice-9/eval.scm:
 432: 1 [eval # #]
In unknown file:
   ?: 0 [uniform-vector-read! #s16(0) #<input: string 8263d20> ...]

ERROR: In procedure uniform-vector-read!:
ERROR: In procedure get-bytevector-n!: Value out of range: 4

[-- Attachment #1.5: Type: text/plain, Size: 445 bytes --]


FWIW, Guile 1.8.8 produces same output as ‘ok’ on a similar (sans the
‘use-modules’ and ‘uniform-vector-element-size’ noise) input, so i think
this situation is a regression.  Am i missing something?

-- 
Thien-Thi Nguyen
   GPG key: 4C807502
   (if you're human and you know it)
      read my lisp: (responsep (questions 'technical)
                               (not (via 'mailing-list)))
                     => nil

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* bug#15370: weirdness w/ uniform-vector-read! compat
  2013-09-13 15:49 bug#15370: weirdness w/ uniform-vector-read! compat Thien-Thi Nguyen
@ 2013-10-20  8:59 ` Ian Price
       [not found]   ` <87iowsfd9k.fsf@zigzag.favinet>
  2013-10-20 17:18   ` Mark H Weaver
  0 siblings, 2 replies; 5+ messages in thread
From: Ian Price @ 2013-10-20  8:59 UTC (permalink / raw)
  To: Thien-Thi Nguyen; +Cc: 15370

Thien-Thi Nguyen <ttn@gnu.org> writes:

> ERROR: In procedure uniform-vector-read!:
> ERROR: In procedure get-bytevector-n!: Value out of range: 4
>
> FWIW, Guile 1.8.8 produces same output as ‘ok’ on a similar (sans the
> ‘use-modules’ and ‘uniform-vector-element-size’ noise) input, so i think
> this situation is a regression.  Am i missing something?

You'll notice that if you supply the parameters directly
e.g. (uniform-vector-read! uve port 0 1), it succeeds. That's enough to
pin it down to the lines

  c_end = SCM_UNBNDP (end) ? SCM_BYTEVECTOR_LENGTH (uvec) : scm_to_size_t (end);
  c_end *= c_width;

in scm_uniform_vector_read_x in libguile/deprecated.c 

Bytevector length returns the number of bytes, but end specifies the
index. We should only be multiplying the latter, not the former. Simple
fix is to fold the multiplication into the else branch of the
conditional.

Since this procedure is marked deprecated, I'd like to know how long it
has left before I patch it. Little point fixing it if it's soon...

Cheers
-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"





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

* bug#15370: weirdness w/ uniform-vector-read! compat
       [not found]   ` <87iowsfd9k.fsf@zigzag.favinet>
@ 2013-10-20 14:36     ` Ian Price
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Price @ 2013-10-20 14:36 UTC (permalink / raw)
  To: Thien-Thi Nguyen; +Cc: 15370

Thien-Thi Nguyen <ttn@gnuvola.org> writes:

> I think it is good to fix it regardless of the remaining time.  Leaving
> it in a known-bad state sends a message tinged w/ coercion -- Not Cool.

There has been talk of making the next version the first release of the
next major version. If the next version was the major version it would
likely mean removing deprecations. _That_ is the scenario I am concerned
about, not lording it over you to update your programs. A fix that never
gets released isn't a fix.

-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"





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

* bug#15370: weirdness w/ uniform-vector-read! compat
  2013-10-20  8:59 ` Ian Price
       [not found]   ` <87iowsfd9k.fsf@zigzag.favinet>
@ 2013-10-20 17:18   ` Mark H Weaver
  2013-10-20 19:30     ` Ian Price
  1 sibling, 1 reply; 5+ messages in thread
From: Mark H Weaver @ 2013-10-20 17:18 UTC (permalink / raw)
  To: Ian Price; +Cc: Thien-Thi Nguyen, 15370

Hi Ian,

Ian Price <ianprice90@googlemail.com> writes:

> Thien-Thi Nguyen <ttn@gnu.org> writes:
>
>> ERROR: In procedure uniform-vector-read!:
>> ERROR: In procedure get-bytevector-n!: Value out of range: 4
>>
>> FWIW, Guile 1.8.8 produces same output as ‘ok’ on a similar (sans the
>> ‘use-modules’ and ‘uniform-vector-element-size’ noise) input, so i think
>> this situation is a regression.  Am i missing something?
>
> You'll notice that if you supply the parameters directly
> e.g. (uniform-vector-read! uve port 0 1), it succeeds. That's enough to
> pin it down to the lines
>
>   c_end = SCM_UNBNDP (end) ? SCM_BYTEVECTOR_LENGTH (uvec) : scm_to_size_t (end);
>   c_end *= c_width;
>
> in scm_uniform_vector_read_x in libguile/deprecated.c 
>
> Bytevector length returns the number of bytes, but end specifies the
> index. We should only be multiplying the latter, not the former. Simple
> fix is to fold the multiplication into the else branch of the
> conditional.

Indeed!

> Since this procedure is marked deprecated, I'd like to know how long it
> has left before I patch it. Little point fixing it if it's soon...

It will certainly not be removed in the 2.0.x release series, which will
remain in use for at least another year or so.  Therefore, this should
definitely be fixed.  Would you like to do it?

In any case, thanks for investigating!

     Mark





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

* bug#15370: weirdness w/ uniform-vector-read! compat
  2013-10-20 17:18   ` Mark H Weaver
@ 2013-10-20 19:30     ` Ian Price
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Price @ 2013-10-20 19:30 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: Thien-Thi Nguyen, 15370-done

Mark H Weaver <mhw@netris.org> writes:

> It will certainly not be removed in the 2.0.x release series, which will
> remain in use for at least another year or so.  Therefore, this should
> definitely be fixed.  Would you like to do it?

As long as it wasn't _next_ release, I am happy to fix it.

Patch pushed. Closing.

Cheers ttn
-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"





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

end of thread, other threads:[~2013-10-20 19:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-13 15:49 bug#15370: weirdness w/ uniform-vector-read! compat Thien-Thi Nguyen
2013-10-20  8:59 ` Ian Price
     [not found]   ` <87iowsfd9k.fsf@zigzag.favinet>
2013-10-20 14:36     ` Ian Price
2013-10-20 17:18   ` Mark H Weaver
2013-10-20 19:30     ` Ian Price

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