[Bug libstdc++/105258] std::get_temporary_buffer() does not respect alignment (affects std::stable_sort())
Marco.Porsch at intenta dot de
gcc-bugzilla@gcc.gnu.org
Fri May 31 07:39:05 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105258
Marco Porsch <Marco.Porsch at intenta dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |Marco.Porsch at intenta dot de
--- Comment #6 from Marco Porsch <Marco.Porsch at intenta dot de> ---
When compiled to ARM NEON vector operations, which have strict alignment
requirements, this issue causes a kernel alignment trap and SIGBUS.
See godbolt [1] for an example using Eigen matrix library. Compiled with clang,
the instruction `vst1.64 {d16, d17}, [r0:128]` is generated which crashes if
the pointer value is not aligned properly.
I created a corresponding ticket with Eigen [2] which points to this issue and
has extra info.
Looking at the stdlib implementation of libc++ [3] and MSVC [4] I see a similar
approach as proposed in the attached patch.
[1] https://godbolt.org/z/1TxcTzz53
[2] https://gitlab.com/libeigen/eigen/-/issues/2826
[3]
https://github.com/llvm/llvm-project/blob/main/libcxx/include/__memory/temporary_buffer.h#L26
[4] https://github.com/microsoft/STL/blob/main/stl/inc/xmemory#L1541
More information about the Gcc-bugs
mailing list