]> git.kaiwu.me - njs.git/commitdiff
Fixed lvlhsh test on 64-bit big-endian systems.
authorValentin Bartenev <vbart@nginx.com>
Thu, 15 Nov 2018 09:45:02 +0000 (12:45 +0300)
committerValentin Bartenev <vbart@nginx.com>
Thu, 15 Nov 2018 09:45:02 +0000 (12:45 +0300)
The nxt_murmur_hash2() generated 4-byte hash that was stored in uintptr_t,
which was 8 bytes long on 64-bit systems.  At each iteration, it took the
previous key and hashed it again.

The problem was that it took only the first 4 bytes of the key, and these
4 bytes were always zero on 64-bit big-endian system.  That resulted in
equal keys at each iteration.

The bug was discovered on IBM/S390x.

nxt/test/lvlhsh_unit_test.c

index 7ed6d6ee78e46402f0bf353b82f701f6c1070d9c..ca75022711937cb52a909d47c62b34017990346a 100644 (file)
@@ -196,7 +196,7 @@ static const nxt_mem_proto_t  mem_cache_pool_proto = {
 static nxt_int_t
 lvlhsh_unit_test(nxt_uint_t n)
 {
-    uintptr_t             key;
+    uint32_t              key;
     nxt_uint_t            i;
     nxt_lvlhsh_t          lh;
     nxt_lvlhsh_each_t     lhe;