[lttng-dev] Userspace RCU data alignment

Dmitry Antipov dmantipov at yandex.ru
Wed Jun 3 08:36:13 EDT 2020


I've compiled userspace-rcu with:

CC=gcc CFLAGS='-O0 -g3 -fsanitize=undefined' LIBS='-lubsan' ./configure [xxx]

and see a lot of 'misaligned address' runtime errors like:

  ./doc/examples/urcu-flavors/bp ==>

../include/urcu/static/urcu-bp.h:185:6: runtime error: member access within misaligned address 0x7fcac376a020 for type 'struct urcu_bp_reader', which requires 128 byte alignment
0x7fcac376a020: note: pointer points here
  ca 7f 00 00  01 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
               ^
     #0 0x7fcac372a880 in _urcu_bp_read_unlock ../include/urcu/static/urcu-bp.h:185
     #1 0x7fcac372b0d9 in urcu_bp_read_unlock /home/antipov/userspace-rcu/src/urcu-bp.c:363
     #2 0x4017d5 in main /home/antipov/userspace-rcu/doc/examples/urcu-flavors/bp.c:92
     #3 0x7fcac2bc2041 in __libc_start_main ../csu/libc-start.c:308
     #4 0x40111d in _start (/home/antipov/userspace-rcu/doc/examples/urcu-flavors/bp+0x40111d)

../include/urcu/static/urcu-bp.h:189:2: runtime error: member access within misaligned address 0x7fcac376a020 for type 'struct urcu_bp_reader', which requires 128 byte alignment
0x7fcac376a020: note: pointer points here
  ca 7f 00 00  01 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
               ^
     #0 0x7fcac372a8c1 in _urcu_bp_read_unlock ../include/urcu/static/urcu-bp.h:189
     #1 0x7fcac372b0d9 in urcu_bp_read_unlock /home/antipov/userspace-rcu/src/urcu-bp.c:363
     #2 0x4017d5 in main /home/antipov/userspace-rcu/doc/examples/urcu-flavors/bp.c:92
     #3 0x7fcac2bc2041 in __libc_start_main ../csu/libc-start.c:308
     #4 0x40111d in _start (/home/antipov/userspace-rcu/doc/examples/urcu-flavors/bp+0x40111d)

Is it critical for correctness, or speed, or whatever else?

To whom it may be interesting, some of (probably not all) alignment issues may be fixed
with attached patch.

Dmitry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: urcu_bp_reader_alignment.patch
Type: text/x-patch
Size: 1652 bytes
Desc: not available
URL: <https://lists.lttng.org/pipermail/lttng-dev/attachments/20200603/f4e96797/attachment.bin>


More information about the lttng-dev mailing list