Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第九章Project运行出现段错误,怎么解决? #27

Open
simple1082 opened this issue Jun 23, 2017 · 6 comments
Open

第九章Project运行出现段错误,怎么解决? #27

simple1082 opened this issue Jun 23, 2017 · 6 comments

Comments

@simple1082
Copy link

Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
Core was generated by `bin/run_vo config/default.yaml'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0xb77a4501 in myslam::Frame::Frame(long, double, Sophus::SE3, std::shared_ptrmyslam::Camera, cv::Mat, cv::Mat) () from /home/dan/work/project/0.4/lib/libmyslam.so
(gdb) bt
#0 0xb77a4501 in myslam::Frame::Frame(long, double, Sophus::SE3, std::shared_ptrmyslam::Camera, cv::Mat, cv::Mat) () from /home/dan/work/project/0.4/lib/libmyslam.so
#1 0xb77a47ef in myslam::Frame::createFrame() () from /home/dan/work/project/0.4/lib/libmyslam.so
#2 0x0804b4d6 in main ()

@simple1082 simple1082 changed the title 第九章Prject运行出现段错误,怎么解决? 第九章Project运行出现段错误,怎么解决? Jun 23, 2017
@lbwlele
Copy link

lbwlele commented Jul 5, 2017

一模一样的问题,gdb定位一样也

@lbwlele
Copy link

lbwlele commented Aug 19, 2017

已解决,请检查自己的ubuntu版本,书中要求是ubuntu 14.04而不能是ubuntu kylin 14.04

@zhanzhongwei
Copy link

修改函数Frame::Ptr Frame::createFrame()
将其中的
“return Frame::Ptr( new Frame(factory_id++) );”
修改为
“ Frame::Ptr framePtr = Frame::Ptr(new(std::nothrow) Frame());
if(framePtr != NULL){
framePtr->id_ = factory_id++;
return framePtr;
}“
修改后验证运行OK,其实就是new的时候传入初始化参数导致的问题,但是还没弄明白为什么这样会引起segmentation fault,如果有谁知道的话,可以分享下。

@OUCwangxiang
Copy link

@zhanzhongwei is right!!!!!!

@icylogic
Copy link

icylogic commented Oct 11, 2018

Real Cause:

createFrame() =>
new Frame() =>
Frame.T_c_w_ (of type SE3d)

If you define a structure having members of fixed-size vectorizable Eigen types, you must overload its "operator new" so that it generates 16-bytes-aligned pointers. Fortunately, Eigen provides you with a macro EIGEN_MAKE_ALIGNED_OPERATOR_NEW that does that for you.

more details:

Solution:

add EIGEN_MAKE_ALIGNED_OPERATOR_NEW to frame.h:

class Frame
{
  ...
  SE3                            T_c_w_;      // transform from world to camera
  ...
public:
  ...
  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};

then clean and rebuild ( if you don't know how, just rm -rf build/* )

PS. How to locate this bug

  1. change cmake configuration profile to Debug.
  2. run the program. or use a debugger to get a more clear call stack

screenshot from 2018-10-11 11-54-41

VisualOdometry and other classes that have members of fixed-size vectorizable Eigen types and create objects by newshould also apply this fix. But the above fix seems to be enough for this project.

cc @zhanzhongwei

@chenchen2015
Copy link

楼上正解,另外rm -r build/*就行了,别-rf了容易手抖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants