2016-08-23 26 views
1

我正在更新〜3年的舊代碼,並試圖使一對出Vector2d和Matrix2d崩潰。粗略地說,代碼是Eigen SIGSEGV同時做make_pair

vector<pair<Vector2d, Matrix2d>> list; 
list.resize(points.size()); 
Vector2d md; 
Matrix2d Sd; 
for(int i=0; i<n; i++) { 
    // do stuff to assign elements of md and Sd 
    // ... 
    list[i] = make_pair(md, Sd); // SIGSEGV on this line 
} 

我發現了一個古老的bug看起來在堆棧的最後兩個級別相似,但這個bug被標記爲固定的,我證實,該補丁修補程序是仍然存在。我嘗試了一個簡單的測試用例,但它沒有問題。有沒有人有一個想法可能是什麼問題?

其它信息:

  • Arch Linux的
  • GCC 6.1.1
  • 徵3.2.9

這裏的回溯:

Thread 7 "flightControlle" received signal SIGSEGV, Segmentation fault. 
[Switching to Thread 0x7fffd7152700 (LWP 12024)] 
0x00000000005e846b in _mm_load_pd (__P=0x0) at /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/include/emmintrin.h:119 
119  return *(__m128d *)__P; 
(gdb) bt 
#0 0x00000000005e846b in _mm_load_pd (__P=0x0) at /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/include/emmintrin.h:119 
#1 Eigen::internal::pload<double __vector(2)>(Eigen::internal::unpacket_traits<double __vector(2)>::type const*) (from=0x0) at /usr/include/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h:220 
#2 0x000000000060310b in Eigen::internal::ploadt<double __vector(2), 1>(Eigen::internal::unpacket_traits<double __vector(2)>::type const*) (from=0x0) at /usr/include/eigen3/Eigen/src/Core/GenericPacketMath.h:290 
#3 0x0000000000659523 in Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> >::packet<1> (this=0x0, rowId=0, colId=0) at /usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:184 
#4 0x00000000006a40fe in Eigen::SwapWrapper<Eigen::Matrix<double, 2, 1, 0, 2, 1> >::copyPacket<Eigen::Matrix<double, 2, 1, 0, 2, 1>, 1, 1> (this=0x7fffd7150a30, rowId=0, colId=0, other=...) 
    at /usr/include/eigen3/Eigen/src/Core/Swap.h:100 
#5 0x00000000006a1da3 in Eigen::DenseCoeffsBase<Eigen::SwapWrapper<Eigen::Matrix<double, 2, 1, 0, 2, 1> >, 1>::copyPacketByOuterInner<Eigen::Matrix<double, 2, 1, 0, 2, 1>, 1, 1> (this=0x7fffd7150a30, outer=0, 
    inner=0, other=...) at /usr/include/eigen3/Eigen/src/Core/DenseCoeffsBase.h:548 
#6 0x000000000069fa0e in Eigen::internal::assign_innervec_CompleteUnrolling<Eigen::SwapWrapper<Eigen::Matrix<double, 2, 1, 0, 2, 1> >, Eigen::Matrix<double, 2, 1, 0, 2, 1>, 0, 2>::run (dst=..., src=...) 
    at /usr/include/eigen3/Eigen/src/Core/Assign.h:206 
#7 0x000000000069d1f7 in Eigen::internal::assign_impl<Eigen::SwapWrapper<Eigen::Matrix<double, 2, 1, 0, 2, 1> >, Eigen::Matrix<double, 2, 1, 0, 2, 1>, 2, 2, 0>::run (dst=..., src=...) 
    at /usr/include/eigen3/Eigen/src/Core/Assign.h:342 
#8 0x000000000069af38 in Eigen::DenseBase<Eigen::SwapWrapper<Eigen::Matrix<double, 2, 1, 0, 2, 1> > >::lazyAssign<Eigen::Matrix<double, 2, 1, 0, 2, 1> > (this=0x7fffd7150a30, other=...) 
    at /usr/include/eigen3/Eigen/src/Core/Assign.h:506 
#9 0x000000000069856f in Eigen::DenseBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> >::swap<Eigen::Matrix<double, 2, 1, 0, 2, 1> > (this=0x7fffd7150c90, other=...) 
    at /usr/include/eigen3/Eigen/src/Core/DenseBase.h:384 
#10 0x000000000069591a in Eigen::internal::matrix_swap_impl<Eigen::Matrix<double, 2, 1, 0, 2, 1>, Eigen::Matrix<double, 2, 1, 0, 2, 1>, false>::run (a=..., b=...) 
    at /usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:805 
#11 0x0000000000693785 in Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> >::_swap<Eigen::Matrix<double, 2, 1, 0, 2, 1> > (this=0x7fffd7150c90, other=...) 
    at /usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:682 
#12 0x00000000006923c6 in Eigen::Matrix<double, 2, 1, 0, 2, 1>::swap<Eigen::Matrix<double, 2, 1, 0, 2, 1> > (this=0x7fffd7150c90, other=...) at /usr/include/eigen3/Eigen/src/Core/Matrix.h:334 
#13 0x00000000006909f9 in Eigen::Matrix<double, 2, 1, 0, 2, 1>::operator=(Eigen::Matrix<double, 2, 1, 0, 2, 1>&&) (this=0x0, 
    other=<unknown type in /home/ryantr/Software/FlightControl/Rover/build/flightController, CU 0x5b3bd1, DIE 0x73ce2f>) at /usr/include/eigen3/Eigen/src/Core/Matrix.h:224 
#14 0x000000000068f440 in std::pair<Eigen::Matrix<double, 2, 1, 0, 2, 1>, Eigen::Matrix<double, 2, 2, 0, 2, 2> >::operator=(std::pair<Eigen::Matrix<double, 2, 1, 0, 2, 1>, Eigen::Matrix<double, 2, 2, 0, 2, 2> >&&) (this=0x0, __p=<unknown type in /home/ryantr/Software/FlightControl/Rover/build/flightController, CU 0x5b3bd1, DIE 0x73e9e5>) at /usr/include/c++/6.1.1/bits/stl_pair.h:319 
#15 0x000000000068a452 in ICSL::Quadrotor::VelocityEstimator::calcPriorDistributions (mDeltaList=std::vector of length 1, capacity 1 = {...}, SDeltaList=std::vector of length 1, capacity 1 = {...}, 
    priorDistList=std::vector of length 0, capacity 0, points=std::vector of length 1, capacity 1 = {...}, mv=..., Sv=..., mz=0.050000000000000003, varz=1, focalLength=262.0029296875, dt=0.033000000000000002, 
    omega=...) at /home/ryantr/Software/FlightControl/Rover/src/VelocityEstimator.cpp:566 

這裏的信息對md和Sd的狀態如果有所不同ence:

$1 = {<Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> >> = {<Eigen::MatrixBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> >> = {<Eigen::DenseBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> >> = {<Eigen::internal::special_scalar_op_base<Eigen::Matrix<double, 2, 1, 0, 2, 1>, double, double, Eigen::DenseCoeffsBase<Eigen::Matrix<double, 2, 1, 0, 2, 1>, 3>, false>> = {<Eigen::DenseCoeffsBase<Eigen::Matrix<double, 2, 1, 0, 2, 1>, 3>> = {<Eigen::DenseCoeffsBase<Eigen::Matrix<double, 2, 1, 0, 2, 1>, 1>> = {<Eigen::DenseCoeffsBase<Eigen::Matrix<double, 2, 1, 0, 2, 1>, 0>> = {<Eigen::EigenBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> >> = {<No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, m_storage = {m_data = {array = {-6.5748748779296875, 
      -96.418296813964844}}}}, <No data fields>} 
(gdb) p Sd 
$2 = {<Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 2, 0, 2, 2> >> = {<Eigen::MatrixBase<Eigen::Matrix<double, 2, 2, 0, 2, 2> >> = {<Eigen::DenseBase<Eigen::Matrix<double, 2, 2, 0, 2, 2> >> = {<Eigen::internal::special_scalar_op_base<Eigen::Matrix<double, 2, 2, 0, 2, 2>, double, double, Eigen::DenseCoeffsBase<Eigen::Matrix<double, 2, 2, 0, 2, 2>, 3>, false>> = {<Eigen::DenseCoeffsBase<Eigen::Matrix<double, 2, 2, 0, 2, 2>, 3>> = {<Eigen::DenseCoeffsBase<Eigen::Matrix<double, 2, 2, 0, 2, 2>, 1>> = {<Eigen::DenseCoeffsBase<Eigen::Matrix<double, 2, 2, 0, 2, 2>, 0>> = {<Eigen::EigenBase<Eigen::Matrix<double, 2, 2, 0, 2, 2> >> = {<No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, m_storage = {m_data = {array = {8947423.3324944824, 110733.5419973651, 
      110733.5419973651, 13614569.654632445}}}}, <No data fields>} 
+0

可以確認,n是小於或等於points.size()? –

回答

2

這是一個對齊問題。看到這個intro,在你的情況下,這個page會給你解決方案。總之,無論是使用非取向的類型:

typedef Matrix<double,2,1,DontAlign> Vector2du; 
typedef Matrix<double,2,2,DontAlign> Matrix2du; 
vector<pair<Vector2du, Matrix2du>> list; 

或通過對準分配器到std::vector

vector<pair<Vector2du, Matrix2du>,Eigen::aligned_allocator<pair<Vector2du, Matrix2du>>> list; 
+0

在過去的幾年中有什麼與此有關的變化?或者只是巧合,我以前沒有看到問題? – ryan0270

+0

我們這邊沒有任何變化,但gcc6默認啓用C++ 11,因此使用移動而不是深度副本(如在回溯中所見)。用-std = C++ 03編譯可能隱藏了這個問題。 – ggael