Skip to content

Commit 5048102

Browse files
Lukas Sismisjasonish
authored andcommitted
hyperscan: prevent LTO opmitizing out hash calculation
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
1 parent cb786f3 commit 5048102

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/util-mpm-hs-cache.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,12 @@ static int HSSaveCache(hs_database_t *hs_db, uint64_t hs_db_hash, const char *ds
222222

223223
uint64_t HSHashDb(const PatternDatabase *pd)
224224
{
225-
uint64_t cached_hash = 0;
226-
uint32_t *hash = (uint32_t *)(&cached_hash);
225+
uint32_t hash[2] = { 0 };
227226
hashword2(&pd->pattern_cnt, 1, &hash[0], &hash[1]);
228227
for (uint32_t i = 0; i < pd->pattern_cnt; i++) {
229228
SCHSCachePatternHash(pd->parray[i], &hash[0], &hash[1]);
230229
}
231-
232-
return cached_hash;
230+
return ((uint64_t)hash[0] << 32) | hash[1];
233231
}
234232

235233
void HSSaveCacheIterator(void *data, void *aux)

0 commit comments

Comments
 (0)