Caught by UBSan: ../lib/eal/x86/include/rte_atomic_64.h:206:21: runtime error: member access within misaligned address 0x7ffd9c67f228 for type 'const rte_int128_t', which requires 16 byte alignment 0x7ffd9c67f228: note: pointer points here 00 00 00 00 c0 5d 3e 00 01 00 00 00 01 00 00 00 00 00 00 00 ^ 00 00 00 00 00 00 00 00 00 00 00 00 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../lib/eal/x86/include/rte_atomic_64.h:206:21 in ../lib/eal/x86/include/rte_atomic_64.h:206:21: runtime error: member access within misaligned address 0x7ffd9c67f228 for type 'const union rte_int128_t::(anonymous at ../lib/eal/include/generic/rte_atomic.h:1102:2)', which requires 16 byte alignment 0x7ffd9c67f228: note: pointer points here 00 00 00 00 c0 5d 3e 00 01 00 00 00 01 00 00 00 00 00 00 00 ^ 00 00 00 00 00 00 00 00 00 00 00 00 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../lib/eal/x86/include/rte_atomic_64.h:206:21 in ../lib/eal/x86/include/rte_atomic_64.h:206:16: runtime error: load of misaligned address 0x7ffd9c67f228 for type 'const uint64_t' (aka 'const unsigned long'), which requires 16 byte alignment 0x7ffd9c67f228: note: pointer points here 00 00 00 00 c0 5d 3e 00 01 00 00 00 01 00 00 00 00 00 00 00 ^ 00 00 00 00 00 00 00 00 00 00 00 00 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../lib/eal/x86/include/rte_atomic_64.h:206:21 in
Rather than explicitly set alignment in callers, mark the structure itself with an alignment constraint. Fixes: 3340202f5954 ("stack: add lock-free implementation") Signed-off-by: David Marchand <david.march...@redhat.com> Acked-by: Bruce Richardson <bruce.richard...@intel.com> Acked-by: Konstantin Ananyev <konstantin.anan...@huawei.com> --- Changes since v4: - dropped ABI exception and updated RN, Changes since v3: - changed rte_stack_lf_head struct alignment, --- doc/guides/rel_notes/release_25_11.rst | 3 +++ lib/stack/rte_stack.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/guides/rel_notes/release_25_11.rst b/doc/guides/rel_notes/release_25_11.rst index ccad6d89ff..aa9211dd60 100644 --- a/doc/guides/rel_notes/release_25_11.rst +++ b/doc/guides/rel_notes/release_25_11.rst @@ -100,6 +100,9 @@ ABI Changes Also, make sure to start the actual text at the margin. ======================================================= +* stack: The structure ``rte_stack_lf_head`` alignment has been updated to 16 bytes + to avoid unaligned accesses. + Known Issues ------------ diff --git a/lib/stack/rte_stack.h b/lib/stack/rte_stack.h index 4439adfc42..fd17ac791d 100644 --- a/lib/stack/rte_stack.h +++ b/lib/stack/rte_stack.h @@ -33,14 +33,14 @@ struct rte_stack_lf_elem { struct rte_stack_lf_elem *next; /**< Next pointer */ }; -struct rte_stack_lf_head { +struct __rte_aligned(16) rte_stack_lf_head { struct rte_stack_lf_elem *top; /**< Stack top */ uint64_t cnt; /**< Modification counter for avoiding ABA problem */ }; struct rte_stack_lf_list { /** List head */ - alignas(16) struct rte_stack_lf_head head; + struct rte_stack_lf_head head; /** List len */ RTE_ATOMIC(uint64_t) len; }; -- 2.50.0