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 at 'MST_linkage_core(N,D,Z)" in Consensus.cpp #27

Open
filipetrocadoferreira opened this issue Sep 28, 2015 · 2 comments

Comments

@filipetrocadoferreira
Copy link

When I'm running the program with a VM the tracker usually crashes at that part of the code, usually when the number of active points is very low.

When I run the code in a native Ubuntu machine, usually I don't have any issue.

@timsee
Copy link

timsee commented Sep 29, 2015

I've played with this algorithm in the past, and I believe the problem you're running into has to do with the case where there is exactly one keypoint.

N,D,Z are initialized like this:

    t_index N = points.size();
    float * D = new float[N*(N-1)/2]; //This is a lot of memory, so we put it on the heap
    cluster_result Z(N-1);

But in the case where there is one keypoint, it simplifies to this:

    t_index N = 1;
    float * D = new float[0]; //This is a lot of memory, so we put it on the heap
    cluster_result Z(0);

This doesn't cause a crash on my native machine, but it would give junk data that gets thrown out since a single keypoint is treated as noise. However, I think it could cause crashes in environments where memory is more controlled, such as a VM.

Have you tried catching the case of keypoints.size() == 1 and throwing it out as early as you can? It may remove the crash.

@glopesdev
Copy link

Yup, I can confirm that bailing out from consensus when number of keypoints is exactly one fixes this for me. Good find!

In fact, I believe issue #10 is just a duplicate of this one.

Will try to submit a pull request with this fix shortly.

glopesdev added a commit to glopesdev/CppMT that referenced this issue Nov 15, 2015
mvines pushed a commit to mvines/CppMT that referenced this issue Jan 23, 2016
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