Potential alignment issue when compiling with "-march=native"
After compiling with "=march=native", I am getting a segfault, which appears to be related to gtsam::noiseModel::Diagonal::Sigmas when I run with valgrind:
==29380== Invalid free() / delete / delete[] / realloc()
==29380== at 0x4C30D3B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==29380== by 0x835F1AA: gtsam::noiseModel::Diagonal::Sigmas(Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, bool) (in /usr/local/lib/libgtsam.so.4.0.0)
==29380== Address 0x2cba3ec0 is 32 bytes inside a block of size 40 alloc'd
==29380== at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==29380== by 0x18EE8C: Eigen::internal::aligned_malloc(unsigned long)
==29380== by 0x1D41CE: Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >::PlainObjectBase<Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1, 0, -1, 1> > >(Eigen::DenseBase<Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1, 0, -1, 1> > > const&)
==29380== by 0x835F192: gtsam::noiseModel::Diagonal::Sigmas(Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, bool) (in /usr/local/lib/libgtsam.so.4.0.0)
I am unsure if it is the same issue as #313 or #414. I tried adding
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
in some of the classes, but that did not solve the issue. I am using Ubuntu 18.04, Eigen 3.3.7, and Boost 1.65.
Comments (4)
-
-
Just a hint on all these annoying Eigen errors: they might happen if different translation units include the headers with
MAKE_ALIGNED_OPERATOR_NEW
with different optimization flags and/or CXXFLAGS. For example, when building the main gtsam libs and the examples / unit tests, all flags should be consistent.One way of solving this would be by using the "modern" CMake way of setting flags as "PUBLIC" so they get automatically imported in all user projects. I'm working on it, but that it would solve this issue is just a "feeling"! ;-)
-
reporter Yes, ensuring flag consistency between GTSAM and the code I was using solved the issue. Although I still had two of the unit tests fail from #414, everything else appears to be working.
-
reporter - changed status to resolved
- Log in to comment
Is there a particular unit test or example this happens with?