GNU bug report logs -
#29132
[PATCH] system: vm: Use 2^32 - 1 as hash size.
Previous Next
Reported by: Mathieu Othacehe <m.othacehe <at> gmail.com>
Date: Fri, 3 Nov 2017 12:50:01 UTC
Severity: normal
Tags: fixed, patch
Done: Mathieu Othacehe <m.othacehe <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29132 in the body.
You can then email your comments to 29132 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#29132
; Package
guix-patches
.
(Fri, 03 Nov 2017 12:50:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Mathieu Othacehe <m.othacehe <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Fri, 03 Nov 2017 12:50:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
* gnu/system/vm.scm (operating-system-uuid): Use 2^32 - 1 instead of
2^32 as hash size.
On some 32 bit system (ARM for example), 2^32 exceeds hash max
size (ULONG_MAX = 2^32 - 1).
---
gnu/system/vm.scm | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 3127b30..4424608 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -372,13 +372,13 @@ TYPE (one of 'iso9660 or 'dce). Return a UUID object."
(bytevector->uuid
(uint-list->bytevector
(list (hash file-system-type
- (expt 2 32))
+ (- (expt 2 32) 1))
(hash (operating-system-host-name os)
- (expt 2 32))
+ (- (expt 2 32) 1))
(hash (operating-system-services os)
- (expt 2 32))
+ (- (expt 2 32) 1))
(hash (operating-system-file-systems os)
- (expt 2 32)))
+ (- (expt 2 32) 1)))
(endianness little)
4)
type)))
--
2.7.4
Information forwarded
to
guix-patches <at> gnu.org
:
bug#29132
; Package
guix-patches
.
(Sun, 05 Nov 2017 20:49:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 29132 <at> debbugs.gnu.org (full text, mbox):
Hello!
Mathieu Othacehe <m.othacehe <at> gmail.com> skribis:
> * gnu/system/vm.scm (operating-system-uuid): Use 2^32 - 1 instead of
> 2^32 as hash size.
>
> On some 32 bit system (ARM for example), 2^32 exceeds hash max
> size (ULONG_MAX = 2^32 - 1).
> ---
> gnu/system/vm.scm | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
> index 3127b30..4424608 100644
> --- a/gnu/system/vm.scm
> +++ b/gnu/system/vm.scm
> @@ -372,13 +372,13 @@ TYPE (one of 'iso9660 or 'dce). Return a UUID object."
> (bytevector->uuid
> (uint-list->bytevector
> (list (hash file-system-type
> - (expt 2 32))
> + (- (expt 2 32) 1))
‘hash’ is documented like this:
-- Scheme Procedure: hash key size
-- Scheme Procedure: hashq key size
-- Scheme Procedure: hashv key size
-- C Function: scm_hash (key, size)
-- C Function: scm_hashq (key, size)
-- C Function: scm_hashv (key, size)
Return a hash value for KEY. This is a number in the range 0 to
SIZE-1, which is suitable for use in a hash table of the given
SIZE.
So I take it that you always get something in the range 0–2³²-1, no?
Ludo’.
Information forwarded
to
guix-patches <at> gnu.org
:
bug#29132
; Package
guix-patches
.
(Sun, 05 Nov 2017 20:57:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 29132 <at> debbugs.gnu.org (full text, mbox):
Hey Ludo,
> So I take it that you always get something in the range 0–2³²-1, no?
Well I agree, but looking to hash code, we have :
--8<---------------cut here---------------start------------->8---
#define FUNC_NAME s_scm_hash
{
unsigned long sz = scm_to_unsigned_integer (size, 1, ULONG_MAX);
--8<---------------cut here---------------end--------------->8---
And 2^32 > ULONG_MAX == 2^32 - 1 on ARM.
This results in this exception :
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (hash 'test (expt 2 32))
ERROR: In procedure hash:
ERROR: Value out of range 1 to 4294967295: 4294967296
--8<---------------cut here---------------end--------------->8---
Mathieu
Information forwarded
to
guix-patches <at> gnu.org
:
bug#29132
; Package
guix-patches
.
(Mon, 06 Nov 2017 08:42:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 29132 <at> debbugs.gnu.org (full text, mbox):
Mathieu Othacehe <m.othacehe <at> gmail.com> skribis:
> Hey Ludo,
>
>> So I take it that you always get something in the range 0–2³²-1, no?
>
> Well I agree, but looking to hash code, we have :
>
> #define FUNC_NAME s_scm_hash
> {
> unsigned long sz = scm_to_unsigned_integer (size, 1, ULONG_MAX);
Oh, got it. Well, OK for the patch!
Thank you,
Ludo’.
Information forwarded
to
guix-patches <at> gnu.org
:
bug#29132
; Package
guix-patches
.
(Mon, 06 Nov 2017 19:05:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 29132 <at> debbugs.gnu.org (full text, mbox):
> Oh, got it. Well, OK for the patch!
Thanks, pushed as b1a30793477c705a136546798d8e1d27802dd4b7.
Added tag(s) fixed.
Request was from
Mathieu Othacehe <m.othacehe <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Mon, 06 Nov 2017 19:06:02 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
29132 <at> debbugs.gnu.org and Mathieu Othacehe <m.othacehe <at> gmail.com>
Request was from
Mathieu Othacehe <m.othacehe <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Mon, 06 Nov 2017 19:06:03 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 05 Dec 2017 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 258 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.