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
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.
Added a workaround for misaligned SubmapSlice structure between cartographer and cartographer_ros built using different compilers or compilation contexts
Rearranged SubmapSlice field order after static analysis performed with clangd
Added commented non-portable workaround with #pragma pack
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 intocartographer_ros
or another external project misaligned by 48 bytes because of differentsizeof()
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 ofSubmapSlice
structure to 32 bytes as is required by GCC.#pragma pack