cartographer-project / cartographer

Cartographer is a system that provides real-time simultaneous localization and mapping (SLAM) in 2D and 3D across multiple platforms and sensor configurations.
Apache License 2.0
7.03k stars 2.24k forks source link

Workaround for misalignment of `SubmapSlice` and Eigen data structures in heterogeneous builds #1910

Open twdragon opened 1 year ago

twdragon commented 1 year ago

Due to different structure alignment rules in different compilers (or even the same compiler in different compiling contexts), the SubmapSlice structure defined in ./cartographer/io/submap_painter.h comes into cartographer_ros or another external project misaligned by 48 bytes because of different sizeof() return values (224 vs 256 bytes). This behaviour is proven when testing Cartographer compiled using Clang 15 and GCC 11.3 on Mint Linux 22 with a customized build of ROS. The reason is deeply sitting problem with implementation-defined STL shipped with different kernels and build pipelines. This pull request adds a semi-portable workaround for this issue forcing alignment of SubmapSlice structure to 32 bytes as is required by GCC.

twdragon commented 1 year ago

This issue persists also in other parts of the project, so I will continue the investigation

twdragon commented 1 year ago

Updated involving the DISABLE_AVX_ALIGNMENT CMake option to disable Eigen-side AVX alignment issues on recent CPUs