I want to use MurmurHash3 in a deduplication system with no adversary. So Murmurhash3 will hash files, for instance.
However I am having problems using it, meaning I am doing something wrong.
Murmurhash3_x86_128() (source-code) function receives four parameters. This is my understanding of what they are:
key - input data to hash
len - data length
seed - seed
out - computed hash value
When running it fails with segmentation faults, because of this part of the code:
void MurmurHash3_x86_128 ( const void * key, const uint32_t len,
uint32_t seed, void * out )
{
const uint8_t * data = (const uint8_t*)key;
const uint32_t nblocks = len / 16;
...
const uint32_t * blocks = (const uint32_t *)(data + nblocks*16);
for(i = -nblocks; i; i++)
{
uint32_t k1 = blocks[i*4];
...
}
...
}
So if my data has length greater than 15 bytes (which is the case), this for loop is executed. However, blocks is pointed to the end of my data array and then it starts accessing memory positions after that position. The segmentation faults are explained. So key can't be just my data array.
My question is: What should I put in key parameter?
Problem Solved
After the answer of Mats Petersson I realized my code had a bug. i must be an int (signed) and I had it unsigned. That is the reason why it was adding memory positions to blocks and not subtracting.