High CPU load and no return value with 3.0.0

  • Open
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Roel Janssen
Owner
unassigned
Submitted by
Roel Janssen
Severity
normal
Merged with
R
R
Roel Janssen wrote on 9 Mar 2020 13:13
(address . bug-guile@gnu.org)
1dc6670b0cd28fb5a899fdf7afe0624007747c81.camel@gnu.org
Dear Guile hackers,

When I use the "md5" module from guile-lib (release 0.2.6.1) together
with the following snippet in Guile 3.0.0, it never returns, while on
Guile 2.2.6, it returns the MD5 sum of the input string:
---
(use-modules (md5))

(define (md5-from-string input)
(call-with-input-string input md5))

(define (random-ascii length)
"Returns a random string of ASCII characters of length LENGTH."
(list->string
(map (lambda _ (integer->char (+ (random 95) 32)))
(iota length))))

(display
(md5-from-string
(random-ascii 32)))
---

Could you point me in the right direction for finding the problem?

This could be completely off-topic:
I also noticed that the function "read-string!/partial" (used by the
md5 module) no longer appears in the manual since the Guile 2.2. Is
the usage of this function considered deprecated?

Kind regards,
Roel Janssen
L
L
Ludovic Courtès wrote on 11 Mar 2020 12:07
(name . Roel Janssen)(address . roel@gnu.org)(address . 39997@debbugs.gnu.org)
87eetzm9oq.fsf@gnu.org
Hi,

Roel Janssen <roel@gnu.org> skribis:

Toggle quote (22 lines)
> When I use the "md5" module from guile-lib (release 0.2.6.1) together
> with the following snippet in Guile 3.0.0, it never returns, while on
> Guile 2.2.6, it returns the MD5 sum of the input string:
> ---
> (use-modules (md5))
>
> (define (md5-from-string input)
> (call-with-input-string input md5))
>
> (define (random-ascii length)
> "Returns a random string of ASCII characters of length LENGTH."
> (list->string
> (map (lambda _ (integer->char (+ (random 95) 32)))
> (iota length))))
>
> (display
> (md5-from-string
> (random-ascii 32)))
> ---
>
> Could you point me in the right direction for finding the problem?

The Guix package has this patch:

'(begin
;; Work around miscompilation on Guile 3.0.0 at -O2:
(substitute* "src/md5.scm"
(("\\(define f-ash ash\\)")
"(define f-ash (@ (guile) ash))\n")
(("\\(define f-add \\+\\)")
"(define f-add (@ (guile) +))\n"))
#t)

It’s very likely that you’re hitting this problem.

HTH!

Ludo’.
L
L
Ludovic Courtès wrote on 11 Mar 2020 12:15
control message for bug #39251
(address . control@debbugs.gnu.org)
87zhcnkuqh.fsf@gnu.org
merge 39251 39997
quit
R
R
Roel Janssen wrote on 11 Mar 2020 14:03
Re: bug#39997: High CPU load and no return value with 3.0.0
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 39997@debbugs.gnu.org)
a42e8bfb36ecf5b3a240f8324af41609f20d34ed.camel@gnu.org
On Wed, 2020-03-11 at 12:07 +0100, Ludovic Courtès wrote:
Toggle quote (42 lines)
> Hi,
>
> Roel Janssen <roel@gnu.org> skribis:
>
> > When I use the "md5" module from guile-lib (release 0.2.6.1)
> > together
> > with the following snippet in Guile 3.0.0, it never returns, while
> > on
> > Guile 2.2.6, it returns the MD5 sum of the input string:
> > ---
> > (use-modules (md5))
> >
> > (define (md5-from-string input)
> > (call-with-input-string input md5))
> >
> > (define (random-ascii length)
> > "Returns a random string of ASCII characters of length LENGTH."
> > (list->string
> > (map (lambda _ (integer->char (+ (random 95) 32)))
> > (iota length))))
> >
> > (display
> > (md5-from-string
> > (random-ascii 32)))
> > ---
> >
> > Could you point me in the right direction for finding the problem?
>
> The Guix package has this patch:
>
> '(begin
> ;; Work around miscompilation on Guile 3.0.0 at -O2:
> ;; <https://bugs.gnu.org/39251>;.
> (substitute* "src/md5.scm"
> (("\\(define f-ash ash\\)")
> "(define f-ash (@ (guile) ash))\n")
> (("\\(define f-add \\+\\)")
> "(define f-add (@ (guile) +))\n"))
> #t)
>
> It’s very likely that you’re hitting this problem.

Yes! Thanks for sharing this fix.
I applied the same changes to my code and now I don't encounter the bug
anymore.

I tested the patched code with both guile-2.2 and guile-3.0. Do you
know whether this will also work with guile-2.0? (I'd like to keep
things compatible with guile-2.0 for a few more years).

Kind regards,
Roel Janssen
L
L
Ludovic Courtès wrote on 11 Mar 2020 15:05
(name . Roel Janssen)(address . roel@gnu.org)(address . 39997@debbugs.gnu.org)
8736afj8aw.fsf@gnu.org
Roel Janssen <roel@gnu.org> skribis:

Toggle quote (2 lines)
> On Wed, 2020-03-11 at 12:07 +0100, Ludovic Courtès wrote:

[...]

Toggle quote (22 lines)
>> The Guix package has this patch:
>>
>> '(begin
>> ;; Work around miscompilation on Guile 3.0.0 at -O2:
>> ;; <https://bugs.gnu.org/39251>;.
>> (substitute* "src/md5.scm"
>> (("\\(define f-ash ash\\)")
>> "(define f-ash (@ (guile) ash))\n")
>> (("\\(define f-add \\+\\)")
>> "(define f-add (@ (guile) +))\n"))
>> #t)
>>
>> It’s very likely that you’re hitting this problem.
>
> Yes! Thanks for sharing this fix.
> I applied the same changes to my code and now I don't encounter the bug
> anymore.
>
> I tested the patched code with both guile-2.2 and guile-3.0. Do you
> know whether this will also work with guile-2.0? (I'd like to keep
> things compatible with guile-2.0 for a few more years).

Yes, the change above also works for Guile 2.0.

Ludo’.
L
L
Ludovic Courtès wrote on 11 Mar 2020 15:06
control message for bug #39251
(address . control@debbugs.gnu.org)
871rpzj89m.fsf@gnu.org
merge 39251 39997
quit
R
R
Roel Janssen wrote on 11 Mar 2020 15:11
Re: bug#39997: High CPU load and no return value with 3.0.0
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 39997-close@debbugs.gnu.org)
50786c56cd6b9632cdfb6e2c2f95e97c1758591d.camel@gnu.org
On Wed, 2020-03-11 at 15:05 +0100, Ludovic Courtès wrote:
Toggle quote (32 lines)
> Roel Janssen <roel@gnu.org> skribis:
>
> > On Wed, 2020-03-11 at 12:07 +0100, Ludovic Courtès wrote:
>
> [...]
>
> > > The Guix package has this patch:
> > >
> > > '(begin
> > > ;; Work around miscompilation on Guile 3.0.0 at -O2:
> > > ;; <https://bugs.gnu.org/39251>;;.
> > > (substitute* "src/md5.scm"
> > > (("\\(define f-ash ash\\)")
> > > "(define f-ash (@ (guile) ash))\n")
> > > (("\\(define f-add \\+\\)")
> > > "(define f-add (@ (guile) +))\n"))
> > > #t)
> > >
> > > It’s very likely that you’re hitting this problem.
> >
> > Yes! Thanks for sharing this fix.
> > I applied the same changes to my code and now I don't encounter the
> > bug
> > anymore.
> >
> > I tested the patched code with both guile-2.2 and guile-3.0. Do
> > you
> > know whether this will also work with guile-2.0? (I'd like to keep
> > things compatible with guile-2.0 for a few more years).
>
> Yes, the change above also works for Guile 2.0.

Thanks for the confirmation. I'm closing this bug, as it is basically
a duplicate of #39251.

Kind regards,
Roel Janssen
?