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

Segmentation fault in the CandidatePoint::observe() #9

Closed
laxnpander opened this issue Jan 16, 2020 · 8 comments
Closed

Segmentation fault in the CandidatePoint::observe() #9

laxnpander opened this issue Jan 16, 2020 · 8 comments

Comments

@laxnpander
Copy link

laxnpander commented Jan 16, 2020

Hey hey,

I just tried running your code. Compiling it was working fine, however after trying to execute on Euroc MH1 the following problem arises: The QT window opens, I press start, I see the SLAM running but after a few failed attempts to initialise I guess he finally manages to initialise but then SegFaults.

Thread 28 "EurocExample" received signal SIGSEGV, Segmentation fault.
#0 0x00007ffff76b9e71 in dsm::CandidatePoint::observe(std::shared_ptrdsm::Frame const&) () at /home/alex/Documents/Projects/dsm_slam/dsm/build/lib/libdsm.so
#1 0x00007ffff76f12aa in dsm::FullSystem::PointObserver::operator()() () at /home/alex/Documents/Projects/dsm_slam/dsm/build/lib/libdsm.so
#2 0x00007ffff76ff6bc in dsm::WorkerThreadPool::workerLoop(unsigned long) () at /home/alex/Documents/Projects/dsm_slam/dsm/build/lib/libdsm.so
#3 0x00007ffff234866f in () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff71ad6db in start_thread (arg=0x7fff88ff9700) at pthread_create.c:463
#5 0x00007ffff1da388f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

FYI: I am running Ubuntu 18.04.

Best regards,
Alex

@laxnpander laxnpander changed the title Segmentation fault in the workerLoop() Segmentation fault in the CandidatePoint::observe() Jan 16, 2020
@jzubizarreta
Copy link
Owner

I do not know what could be happening. We have tried DSM in many different computers and it is working fine.

Please try to debug it using the single threaded options and write back with further information.

@laxnpander
Copy link
Author

laxnpander commented Jan 19, 2020

If I read your Euroc settings.txt right, single threaded is already activated by default?

It also seems to occure faster the more mapping threads I use. So something might not be threadsafe?

Edit: Here is the gdb backtrace:

#0 0x00007ffff76c293e in std::__min_element<__gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator > >, __gnu_cxx::__ops::_Iter_less_iter>(__gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator > >, __gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator > >, __gnu_cxx::__ops::_Iter_less_iter) (__last=non-dereferenceable iterator for std::vector, __first=non-dereferenceable iterator for std::vector, __comp=...) at /usr/include/c++/7/bits/stl_algo.h:5585
#1 0x00007ffff76c293e in std::min_element<__gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator > > >(__gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator > >, __gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator > >) (__last=non-dereferenceable iterator for std::vector, __first=non-dereferenceable iterator for std::vector) at /usr/include/c++/7/bits/stl_algo.h:5614
#2 0x00007ffff76c293e in dsm::CandidatePoint::observe(std::shared_ptrdsm::Frame const&) (this=0x7fff4837aec0, other=...)
at /home/alex/Documents/Projects/dsm_slam/dsm/dsm/src/DataStructures/CandidatePoint.cpp:335
#3 0x00007ffff76f207a in dsm::FullSystem::PointObserver::operator()() (this=0x7fff4815fe20) at /home/alex/Documents/Projects/dsm_slam/dsm/dsm/src/FullSystem/FullSystem.cpp:1727
#4 0x00007ffff76ff12c in std::function<void ()>::operator()() const (this=0x7fff63ff79d0) at /usr/include/c++/7/bits/std_function.h:706
#5 0x00007ffff76ff12c in dsm::WorkerThreadPool::workerLoop(unsigned long) (this=0x7fff9c001550, id=)
at /home/alex/Documents/Projects/dsm_slam/dsm/dsm/src/Thread/WorkerThreadPool.h:189
#6 0x00007ffff235266f in () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7 0x00007ffff71b76db in start_thread (arg=0x7fff63fff700) at pthread_create.c:463
#8 0x00007ffff1dad88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Looks like line #335 in observe() causes the trouble. With some print statements I found out that vector "errors" has size() = 0, so it is trying to dereference an empty vector. I traced that back to a epipolar line length of 0.

I will try to investigate more when I have time!

@jzubizarreta
Copy link
Owner

Yes, single thread is activated by default. Please try to use mappingThreads = 1 and see what is going on.

Thanks!

@laxnpander
Copy link
Author

laxnpander commented Jan 19, 2020

@jzubizarreta: I almost found the problem. Parsing the settings from file does something it should not and sets some of the parameters to 0.

Edit: Okay, I found it. Names of the parameters in the Example settings file are not larger/lower case appropriate :)

@jzubizarreta
Copy link
Owner

The settings parser transforms each line to lower case and removes spaces. In theory, there should not be any problem with that.

Tell me if you find any bug please, so I can fix it.

Thanks again!

@laxnpander
Copy link
Author

@jzubizarreta: You are right, I see it now. But there is definitely a problem reading the settings in my case. I will let you know when I found out more!

@laxnpander
Copy link
Author

laxnpander commented Jan 20, 2020

@jzubizarreta: Okay I found the problem, though it is really weird. I am German and my "atof" function seems to expect floating point numbers to be separated by comma. I added the following line:
std::setlocale(LC_ALL, "en_US.UTF-8");
Now it is reading all parameters correctly. The weird part: When I wrote the parameters with capital letters just like in the settings file, it was working correctly.

But jeah, that might stay one of the mysteries of the C++ language...

hobbeshunter added a commit to hobbeshunter/dsm that referenced this issue Oct 15, 2020
fixes jzubizarreta#9

If not set floating points will not be parsed correctly by atof
for e.g. Germans
@brendanlb
Copy link

Hello,

I had the same problem, which was solved using @laxnpander setlocale solution. It would be nice to commit it !

Brendan

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

3 participants