In
328c2fe7297c941aa9cbcfa4ce944fca1bd7300f, the type of 'lttng_uuid'
was changed from a C array of 16 'uint8_t' to a C++ std::array of the
same type and length.
In 'trace_chunk_registry_ht_key_hash()' we access these 16 bytes as 2
'uint64_t', to do so we used to cast the array to '(uint64_t *)' and
then access index 0 and 1.
When it was converted to C++, an error was introduced where instead we
reinterpret_cast to 'const uint64_t *' the index 0 and 1 of the array
which results in a 'uint64_t' pointer to the first and second bytes of
the array. These values overlap but since they are used as keys for an
hash table it still works. However, on platforms that don't allow
unaligned access, the second pointer being only offset by one byte
results in a 'Bus error'.
Reintroduce the old behavior by applying the index 0 and 1 to the
pointer resulting from the reinterpret_cast.
Change-Id: I2bc287edbe6864a2a870f9de1f3b4dd8f8a90ace
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
static unsigned long trace_chunk_registry_ht_key_hash(const struct trace_chunk_registry_ht_key *key)
{
- const uint64_t uuid_h1 = *reinterpret_cast<const uint64_t *>(&key->sessiond_uuid[0]);
- const uint64_t uuid_h2 = *reinterpret_cast<const uint64_t *>(&key->sessiond_uuid[1]);
+ const uint64_t uuid_h1 = reinterpret_cast<const uint64_t *>(key->sessiond_uuid.data())[0];
+ const uint64_t uuid_h2 = reinterpret_cast<const uint64_t *>(key->sessiond_uuid.data())[1];
return hash_key_u64(&uuid_h1, lttng_ht_seed) ^ hash_key_u64(&uuid_h2, lttng_ht_seed);
}