SIGSEGV in flann getNeighbors function [closed]

asked 2016-02-01 17:18:13 -0600

phirestalker gravatar image

updated 2016-02-02 14:41:37 -0600

UPDATE: got it working great now, I had to make the index data global and pad the query descriptors to match the index cols. Thanks all for the help

ok since this is a runtime error I am going to upload the entire qt project, which isn't that large yet, just too large to copy paste. I will also paste the partial backtrace. It is happening with one file so far, but it is the largest file. I will post a link to the file as well.

video: https://www.dropbox.com/s/e8hzpir7udp... project: https://www.dropbox.com/s/uyz0p4zck3p...

and here is the backtrace. I just have no idea what could be causing this, as it works for other videos

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x1e37 of process 1491]
0x00000001013c02df in cvflann::LshIndex<cvflann::HammingLUT>::getNeighbors(unsigned char const*, cvflann::ResultSet<int>&) () from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
(gdb) backtrace
#0  0x00000001013c02df in cvflann::LshIndex<cvflann::HammingLUT>::getNeighbors(unsigned char const*, cvflann::ResultSet<int>&) () from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
#1  0x00000001013bdc49 in cvflann::LshIndex<cvflann::HammingLUT>::knnSearch(cvflann::Matrix<unsigned char> const&, cvflann::Matrix<int>&, cvflann::Matrix<int>&, int, cvflann::SearchParams const&) ()
   from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
#2  0x00000001013e0d1a in void cv::flann::runKnnSearch_<cvflann::HammingLUT, cvflann::Index<cvflann::HammingLUT> >(void*, cv::Mat const&, cv::Mat&, cv::Mat&, int, cv::flann::SearchParams const&) ()
   from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
#3  0x00000001013b4b1a in cv::flann::Index::knnSearch(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, cv::flann::SearchParams const&) ()
   from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
#4  0x0000000100016334 in MainWindow::findDupes (this=0x7fff5fbff788, frame=...)
    at ../VideoTwin/mainwindow.cpp:318
#5  0x000000010001aff7 in MainWindow::on_scanwatcher_finished()::AddWrapper::operator()(MainWindow::frm&) (this=0x10641e678, data=...) at ../VideoTwin/mainwindow.cpp:298
#6  0x000000010001ae46 in QtConcurrent::MapKernel<QList<MainWindow::frm>::iterator, MainWindow::on_scanwatcher_finished()::AddWrapper>::runIteration(QList<MainWindow::frm>::iterator, int, void*) (
    this=0x10641e640, it=...)
    at /usr/local/Cellar/qt5/5.5.1_2/lib/QtConcurrent.framework/Headers/qtconcurrentmapkernel.h:63
#7  0x000000010001aed9 in QtConcurrent::MapKernel<QList<MainWindow::frm>::iterator, MainWindow::on_scanwatcher_finished()::AddWrapper>::runIterations(QList<MainWindow::frm>::iterator, int, int, void*) (this=0x10641e640, sequenceBeginIterator=..., beginIndex=6, endIndex=7)
    at /usr/local/Cellar/qt5/5.5.1_2/lib/QtConcurrent.framework/Headers/qtconcurrentmapkernel.h:72
#8  0x000000010002545a in QtConcurrent::IterateKernel<QList<MainWindow::frm>::iterator, void>::forThreadFunction() ()
#9  0x0000000100024f97 in QtConcurrent::IterateKernel<QList<MainWindow::frm>::iterator, void>::threadFunction() ()
#10 0x0000000100025072 in virtual thunk to QtConcurrent::IterateKernel<QList<MainWindow::frm>::iterator, void>::threadFunction() ()
---Type <return> to continue, or q <return> to quit---kill
#11 0x00000001045b94ac in QtConcurrent::ThreadEngineBase::run() ()
   from /usr/local/opt/qt5/lib/QtConcurrent.framework/Versions/5/QtConcurrent
#12 0x0000000103faa737 in QThreadPoolThread::run() ()
   from /usr/local/opt/qt5/lib/QtCore.framework/Versions/5/QtCore
#13 0x0000000103fadc02 in QThreadPrivate::start(void*) ()
   from /usr/local/opt/qt5/lib/QtCore.framework/Versions/5/QtCore
#14 0x00007fffa037cc13 in __FunctionTableTransposed_AVX10 ()
   from /usr/lib/system/libsystem_pthread.dylib
#15 ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by berak
close date 2016-02-03 07:39:20.810831

Comments

1

if you want help, please give us a minimal relevant code snippet to reproduce, not your whole codebase on dropbox.

berak gravatar imageberak ( 2016-02-01 22:06:54 -0600 )edit

that's just it, there is no minimal. I can try to spend the whole day tomorrow copying and pasting trying to give a compilable example so that it can be reproduced

the problem is I don't know what to leave out, because you have to run the program with the video file and it has to process it like my whole program would to get the error.

phirestalker gravatar imagephirestalker ( 2016-02-01 22:17:55 -0600 )edit

I just have no idea what could be causing this, as it works for other videos --> did you actually check if that single video file is not corrupt? Missing frames? ...

StevenPuttemans gravatar imageStevenPuttemans ( 2016-02-02 06:33:02 -0600 )edit
2

flann::Index has a tendency to "run away with naked pointers" from data you feed in as a cv::Mat. make sure, your train data is still valid, when calling findNearest() or similar.

berak gravatar imageberak ( 2016-02-02 06:56:45 -0600 )edit

@StevenPuttemans, yes I do a lot of checking on the frames. I check the frame mat for empty, I check iscontinuous then I check the descriptors mat after computing for the same checks and drop them if they fail. I also pad them with zeros to make them the same size for the index. The console shows video errors from the ffmpeg backend and I don't see any. Also ffprobe shows no errors: /usr/local/bin/ffprobe -v quiet -print_format json -show_error /Users/phire/Dropbox/Geoengineering\ 1\ hour\ vid.m4v had blank output

@berak, wait, do you mean that the data I pass to the index() call needs to be global? or at least accesible from the function that I call knnsearch from? If that's the case why wouldn't it crash every time?

phirestalker gravatar imagephirestalker ( 2016-02-02 11:49:26 -0600 )edit

ok I made the index data global and now I get

Assertion failed: (queries.cols == veclen()), function knnSearch, file /tmp/opencv320160131-91598-1dax8xj/opencv-3.1.0/modules/flann/include/opencv2/flann/lsh_index.h, line 192.

phirestalker gravatar imagephirestalker ( 2016-02-02 13:12:32 -0600 )edit