nikolaradulov / SLAMFuse

SLAM performance evaluation framework
https://apt.cs.manchester.ac.uk/projects/PAMELA/
Other
8 stars 1 forks source link

SLAM-EDS Eigen segfault #24

Closed nikolaradulov closed 2 months ago

nikolaradulov commented 1 year ago

Eigen segfaults on conservativeResize within the EDS library, but not when called on the same matrix from the main driver of the algorithm in Task.cpp. In both instances the version used is 3.3.7 as reported by executing std::cout<<"Eigen World lib: "<<EIGEN_WORLD_VERSION<<" Eigen Major lib: "<<EIGEN_MAJOR_VERSION<<" Eigen Minor lib: "<<EIGEN_MINOR_VERSION<<'\n'; . The stack traced by GDB is :

#0  0x00007ffff385665e in _mm_loadu_pd (__P=0x30000017dae08) at /usr/lib/gcc/x86_64-linux-gnu/9/include/emmintrin.h:131
#1  Eigen::internal::ploadu<double __vector(2)>(Eigen::internal::unpacket_traits<double __vector(2)>::type const*) (from=0x30000017dae08) at /usr/include/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h:336
#2  0x00007ffff39288f1 in Eigen::internal::ploadt<double __vector(2), 0>(Eigen::internal::unpacket_traits<double __vector(2)>::type const*) (from=0x30000017dae08) at /usr/include/eigen3/Eigen/src/Core/GenericPacketMath.h:465
#3  Eigen::internal::mapbase_evaluator<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >::packet<0, double __vector(2)>(long, long) const (this=0x7fffffffd5e0, row=0, col=1) at /usr/include/eigen3/Eigen/src/Core/CoreEvaluators.h:860
#4  0x00007ffff395207c in Eigen::internal::generic_dense_assignment_kernel<Eigen::internal::evaluator<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> >, Eigen::internal::evaluator<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> >, Eigen::internal::assign_op<double, double>, 0>::assignPacket<16, 0, double __vector(2)>(long, long) (this=0x7fffffffd620, row=0, col=1) at /usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:652
#5  0x00007ffff394bcb3 in Eigen::internal::generic_dense_assignment_kernel<Eigen::internal::evaluator<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> >, Eigen::internal::evaluator<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> >, Eigen::internal::assign_op<double, double>, 0>::assignPacketByOuterInner<16, 0, double __vector(2)>(long, long) (this=0x7fffffffd620, outer=1, inner=0) at /usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:666
#6  0x00007ffff39447db in Eigen::internal::dense_assignment_loop<Eigen::internal::generic_dense_assignment_kernel<Eigen::internal::evaluator<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> >, Eigen::internal::evaluator<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> >, Eigen::internal::assign_op<double, double>, 0>, 4, 0>::run(Eigen::internal::generic_dense_assignment_kernel<Eigen::internal::evaluator<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> >, Eigen::internal::evaluator<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> >, Eigen::internal::assign_op<double, double>, 0>&) (kernel=...) at /usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:551
#7  0x00007ffff393db43 in Eigen::internal::call_dense_assignment_loop<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>, Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>, Eigen::internal::assign_op<double, double> >(Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>&, Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> const&, Eigen::internal::assign_op<double, double> const&) (dst=..., src=..., func=...) at /usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:741
#8  0x00007ffff39350da in Eigen::internal::Assignment<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>, Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>, Eigen::internal::assign_op<double, double>, Eigen::internal::Dense2Dense, void>::run(Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>&, Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> const&, Eigen::internal::assign_op<double, double> const&) (dst=..., src=..., func=...) at /usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:879
#9  0x00007ffff392858d in Eigen::internal::call_assignment_no_alias<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>, Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>, Eigen::internal::assign_op<double, double> >(Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>&, Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> const&, Eigen::internal::assign_op<double, double> const&) (dst=..., src=..., func=...) at /usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:836

#10 0x00007ffff391d7b6 in Eigen::internal::call_assignment<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>, Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>, Eigen::internal::assign_op<double, double> >(Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>&, Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> const&, Eigen::internal::assign_op<double, double> const&, Eigen::internal::enable_if<!Eigen::internal::evaluator_assume_aliasing<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>, Eigen::internal::evaluator_traits<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> >::Shape>::value, void*>::type) (dst=..., src=..., func=...) at /usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:804
#11 0x00007ffff3910a99 in Eigen::internal::call_assignment<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>, Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> >(Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>&, Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> const&) (dst=..., src=...) at /usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:782

#12 0x00007ffff3901a2b in Eigen::MatrixBase<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> >::operator=(Eigen::MatrixBase<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> > const&) (this=0x7fffffffd860, other=...) at /usr/include/eigen3/Eigen/src/Core/Assign.h:57
#13 0x00007ffff38f334b in Eigen::MapBase<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>, 1>::operator=(Eigen::MapBase<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>, 1> const&) (this=0x7fffffffd860, other=...) at /usr/include/eigen3/Eigen/src/Core/MapBase.h:292
#14 0x00007ffff38e736d in Eigen::internal::BlockImpl_dense<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false, true>::operator=(Eigen::internal::BlockImpl_dense<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false, true> const&) (this=0x7fffffffd860, other=...)
    at /usr/include/eigen3/Eigen/src/Core/Block.h:341
#15 0x00007ffff38dd6e5 in Eigen::BlockImpl<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false, Eigen::Dense>::operator=(Eigen::BlockImpl<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false, Eigen::Dense> const&) (this=0x7fffffffd860, other=...) at /usr/include/eigen3/Eigen/src/Core/Block.h:161
#16 0x00007ffff38d2c5f in Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false>::operator=(Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> const&) (this=0x7fffffffd860, other=...) at /usr/include/eigen3/Eigen/src/Core/Block.h:111
#17 0x00007ffff38c7e37 in Eigen::internal::conservative_resize_like_impl<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, false>::run(Eigen::DenseBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, long, long) (_this=..., rows=12, cols=12)
    at /usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:941
#18 0x00007ffff38be9e5 in Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >::conservativeResize(long, long) (this=0x555555c0c768, rows=12, cols=12) at /usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:392
#19 0x00007ffff38b1004 in dso::EnergyFunctional::insertFrame(dso::FrameHessian*, dso::CalibHessian*) (this=0x555555c0c740, fh=0x55555adf2bb0, Hcalib=0x5555566df440) at /home/nrad/slam-eds-slambench/src/orig/eds/src/bundles/EnergyFunctional.cpp:442
#20 0x00007ffff4252736 in eds::Task::initialize(dso::ImageAndExposure*, int, int const&) (this=this@entry=0x7ffff42901a0 <eds_alg>, image=image@entry=0x55555af9f410, id=0, snapped_threshold=@0x7fffffffdadc: 10) at /usr/include/c++/9/bits/shared_ptr_base.h:1309
#21 0x00007ffff4254203 in eds::Task::frameCallback(base::Time const&, base::samples::frame::Frame const&, bool) (this=this@entry=0x7ffff42901a0 <eds_alg>, ts=..., frame_sample=..., frame_interrupt=frame_interrupt@entry=false) at /home/nrad/slam-eds-slambench/src/orig/task/src/Task.cpp:166
#22 0x00007ffff4234658 in sb_process_once(SLAMBenchLibraryHelper*) (slam_settings=<optimized out>) at /home/nrad/slambench/framework/shared/include/TimeStamp.h:29
#23 0x00005555555bf21f in SLAMBenchConfiguration::ComputeLoopAlgorithm(bool*, SLAMBenchUI*) (this=0x5555556e3570, stay_on=<optimized out>, ui=<optimized out>) at /home/nrad/slambench/framework/shared/src/SLAMBenchConfiguration.cpp:419
#24 0x00005555555b1fec in main(int, char**) (argc=5, argv=0x7fffffffdf08) at /home/nrad/slambench/framework/tools/loaders/slambench_app.cpp:116
nikolaradulov commented 1 year ago

To build the library:

git clone git@github.com:nikolaradulov/slam-eds-slambench.git

Install depedencies:


#install eigen
sudo apt-get install libeigen3-dev
# install pcl 
sudo apt-get install libpcl-dev

# Install rock-cmake
cd ~
git clone https://github.com/rock-core/base-cmake.git
cd base-cmake
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$HOME/dev/install ..
make install

export CMAKE_PREFIX_PATH=$HOME/dev/install
export PKG_CONFIG_PATH=$HOME/dev/install/lib/pkgconfig:$HOME/dev/install/share/pkgconfig:$HOME/dev/install/lib64/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=$HOME/dev/install/lib:$HOME/dev/install/lib64:$LD_LIBRARY_PATH
export PATH=$HOME/dev/install/bin:$PATH

cd ~ 
git clone https://github.com/rock-core/base-logging.git
cd base-logging
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$HOME/dev/install ..
make install

cd ~
git clone https://github.com/rock-core/base-types.git
cd base-types
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$HOME/dev/install -DUSE_SISL=OFF -DBINDINGS_RUBY=OFF ..
make install

# install ceres
sudo apt-get install cmake
# google-glog + gflags
sudo apt-get install libgoogle-glog-dev libgflags-dev
# Use ATLAS for BLAS & LAPACK
sudo apt-get install libatlas-base-dev
# SuiteSparse (optional)
sudo apt-get install libsuitesparse-dev
tar zxf ceres-solver-2.1.0.tar.gz
mkdir ceres-bin
cd ceres-bin
cmake ../ceres-solver-2.1.0
make -j3
make test
# Optionally install Ceres, it can also be exported using CMake which
# allows Ceres to be used without requiring installation, see the documentation
# for the EXPORT_BUILD_DIR option for more information.
make install

# install yaml-cpp 
tar zxf yaml-cpp-0.8.0.tar.z
cd yaml-cpp-0.8.0
mkdir build
cd build
cmake -DYAML_BUILD_SHARED_LIBS=ON ..
make install

#Install opencv
sudo apt install libopencv-dev

#install jpeg conversion
git clone https://github.com/rock-core/perception-jpeg_conversion.git
cd perception-jpeg_conversion
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$HOME/dev/install -DBINDINGS_RUBY=OFF ..
make install

#install frame helper
git clone https://github.com/rock-core/perception-frame_helper.git
cd perception-frame_helper
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$HOME/dev/install -DBINDINGS_RUBY=OFF ..
make install

build eds library:

 cd slam-eds-slambench/src/orig/eds
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$HOME/dev/install -DCMAKE_BUILD_TYPE=Debug ..
make install

Build shared library:

cd slam-eds-slambench/src/orig
mkdir build
cd build
cmake -DDEPS_PATH=/home/nrad/dev/install -DWRAPPER_PATH=/home/nrad/slam-eds-slambench/wrapper -DEIGEN3_INCLUDE_DIR=/usr/include/eigen3/ "-DCMAKE_INSTALL_PREFIX:PATH=/home/nrad/slam-eds-slambench/" ..
make install

Run with:

cd slam-eds-slambench/src/orig/build

 ~/slambench/build/bin/slambench -i ~/slambench/datasets/UZHFPV/indoor_forward_5_davis_with_gt.slam -load ./libslam_eds-original-library.so
yuhaozhang7 commented 1 year ago

Is it because the Eigen version conflict? SLAMBenchAPI.h and SLAMBenchLibraryHelper.h (included by SLAMBenchAPI.h) include <Eigen/Core>, but it doesn't seems to be the problem because they are just header file ... and I am not sure if it is safe to declare a static Eigen variable in library.cpp.

eigen

yuhaozhang7 commented 1 year ago

https://github.com/yuhaozhang7/slam-eds In slambench branch

I simply write a CMakeLists.txt without rock. But I do use rock cmake to install frame_helper, jpeg, base-types, base-logging. I change the location of config.yaml, sensor.yaml and move Task.cpp, Task.hpp, EDSTypes.hpp into task folder, so it becomes in order to include Task.cpp, I use #include "eds/task/Task.hpp"

nikolaradulov commented 2 months ago

Closing issue due to stop in eds dev integration