Hello,

As of the unstable version, redis uses the MurmurHash2 hash function, which assumes that your machine doesn't crash on unaligned reads.

// excerpt from dict.c
/* MurmurHash2, by Austin Appleby
 * Note - This code makes a few assumptions about how your machine behaves -
 * 1. We can read a 4-byte value from any address without crashing
 * 2. sizeof(int) == 4
 *
 * And it has a few limitations -
 *
 * 1. It will not work incrementally.
 * 2. It will not produce the same results on little-endian and big-endian
 *    machines.
 */

The bitopCommand function states (wrongly I think) that sds strings are always 8-byte aligned:

// excerpt from bitops.c
/* Note: sds pointer is always aligned to 8 byte boundary. */

However, this seems to be true only until version 3.0. The unstable version uses the new variable SDS headers, which are not always 8-byte aligned.

Since this code might crash in some platforms, shouldn't redis support an implementation with aligned-reads only?

Comment From: yoav-steinberg

Seems we have since moved to siphen hash (adeed29a99dcd0efdbfe4dbd5da74e7b01966c67) And also handled unaligned access for ARM and SPARC (b3391fd853d55b3da04ede024adcc6bf017c78f1). I'm closing this. If you feel I'm missing something let me know.