我尝试运行一个使用GCC 6.1.1编译的Eigen(3.2.92)的程序。但是,在启动时它会因对齐问题而崩溃:
#3 0x00007ffff4669c82 in __GI___assert_fail (assertion=0x7ffff74319b8 "(reinterpret_cast<size_t>(eigen_unaligned_array_assert_workaround_gcc47(array)) & (31)) == 0 && \"this assertion is explained here: \" \"http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAss"..., file=0x7ffff7431688 "/usr/include/eigen3/Eigen/src/Core/DenseStorage.h", line=128, function=0x7ffff74340a0 <Eigen::internal::plain_array<double, 4, 0, 32>::plain_array()::__PRETTY_FUNCTION__> "Eigen::internal::plain_array<T, Size, MatrixOrArrayOptions, 32>::plain_array() [with T = double; int Size = 4; int MatrixOrArrayOptions = 0]") at assert.c:101
#4 0x00007ffff7399821 in Eigen::internal::plain_array<double, 4, 0, 32>::plain_array (this=0x89ed70) at /usr/include/eigen3/Eigen/src/Core/DenseStorage.h:128
#5 0x00007ffff739861e in Eigen::DenseStorage<double, 4, 2, 2, 0>::DenseStorage (this=0x89ed70) at /usr/include/eigen3/Eigen/src/Core/DenseStorage.h:187
#6 0x00007ffff73a7d37 in Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 2, 0, 2, 2> >::PlainObjectBase (this=0x89ed70) at /usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:457
#7 0x00007ffff73b3720 in Eigen::Matrix<double, 2, 2, 0, 2, 2>::Matrix (this=0x89ed70) at /usr/include/eigen3/Eigen/src/Core/Matrix.h:259
#8 0x00007ffff73b35a5 in svo::Matcher::Matcher (this=0x89ec90) at /home/user/ros2/catkin_ws/src/rpg_svo/svo/include/svo/matcher.h:106
#9 0x00007ffff73b1b33 in svo::Reprojector::Reprojector (this=0x89ec30, cam=0x884820, map=...) at /home/user/ros2/catkin_ws/src/rpg_svo/svo/src/reprojector.cpp:34
#10 0x00007ffff72e0e62 in svo::FrameHandlerMono::FrameHandlerMono (this=0x89eb10, cam=0x884820) at /home/user/ros2/catkin_ws/src/rpg_svo/svo/src/frame_handler_mono.cpp:37
#11 0x000000000040f70a in svo::VoNode::VoNode() ()
#12 0x000000000040bf05 in main ()
以下是相关的代码部分:
class Matcher {
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Matrix2d A_cur_ref_;
Matcher() = default; // <--- matcher.h:106
};
class Reprojector {
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Reprojector(...) // <--- reprojector.cpp:34
{...}
private:
Matcher matcher_;
};
class FrameHandlerMono : public FrameHandlerBase {
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
FrameHandlerMono(...) :
reprojector_(...) // <--- frame_handler_mono.cpp:37
{...}
protected:
Reprojector reprojector_;
};
class VoNode
{
public:
svo::FrameHandlerMono* vo_;
VoNode() {
vo_ = new svo::FrameHandlerMono(...);
}
};
int main() {
svo::VoNode vo_node;
return 0;
}
注释标记gdb报告错误的行。
我查看了mentioned website,但我认为在需要时会涉及EIGEN_MAKE_ALIGNED_OPERATOR_NEW宏。另外,我还将宏添加到VoNode类中,但这并没有解决错误。
更新
我使用GCC 4.8.4和Eigen 3.2.0在类似的机器上编译程序,一切正常。较新的GCC(或C ++ 14作为新的默认值)是否处理与旧的GCC不同的对齐?
更新2
我只是发现Eigen 3.2.92实际上是Eigen 3.3-beta并入了一些changes。使用Eigen 3.2.8我已经能够成功编译和运行该软件。但是,我仍然不知道为什么3.3会导致这些对齐错误。