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:33 +0000 (11:58 -0400)
commit4dbeb34bfa909fd7f75ceeca252cf8a9f24b4fa6
tree8abbe64f562f316af131dcbcc7b1fcba99219a38
parent915252f188073ff13de36ffe83d652b76aa66a85
Fix: misaligned urcu reader accesses

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
src/lib/lttng-ust-common/lttng-ust-urcu.c
This page took 0.025794 seconds and 4 git commands to generate.