Since cached_hash was updated through reference (hash), it seems
LTO did not notice this and optimized the whole code block, returning
zero.
This in turn caused all caches to have the same name and to overwrite.
On subsequent runs, only the last cache was loaded for all SGHs
causing wrong MPM assignment.
Ticket: 7824
uint64_t HSHashDb(const PatternDatabase *pd)
{
- uint64_t cached_hash = 0;
- uint32_t *hash = (uint32_t *)(&cached_hash);
+ uint32_t hash[2] = { 0 };
hashword2(&pd->pattern_cnt, 1, &hash[0], &hash[1]);
for (uint32_t i = 0; i < pd->pattern_cnt; i++) {
SCHSCachePatternHash(pd->parray[i], &hash[0], &hash[1]);
}
-
- return cached_hash;
+ return ((uint64_t)hash[1] << 32) | hash[0];
}
void HSSaveCacheIterator(void *data, void *aux)