Fix: misaligned urcu reader accesses
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 27 Sep 2023 13:41:04 +0000 (09:41 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 29 Sep 2023 15:58:02 +0000 (11:58 -0400)
Running the LTTng-tools tests (test_valid_filter, for example) under
address sanitizer results in the following warning:

  /usr/include/lttng/urcu/static/urcu-ust.h:155:6: runtime error: member access within misaligned address 0x7fc45db3a020 for type 'struct lttng_ust_urcu_reader', which requires 128 byte alignment
  0x7fc45db3a020: note: pointer points here
   c4 7f 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                ^

While the node member of lttng_ust_urcu_reader has an "aligned"
attribute of CAA_CACHE_LINE_SIZE, the compiler can't ensure the
alignment of members for dynamically allocated instances.

The `data` pointer is changed from char* to struct
lttng_ust_urcu_reader*, allowing the compiler to enforce the expected
alignment constraints.

Since `data` was addressed in bytes, the code using this field is
adapted to use element counts. As the chunks are only used to allocate
reader instances (and not other types), it makes the code a bit easier
to read.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic826cf94444681bea3a192d3a9f4262a0961e948


No differences found
This page took 0.027191 seconds and 4 git commands to generate.