Ask Your Question
1

Strange crashes during deallocation of std::vector (VS2015, Windows 7)

asked 2015-07-27 14:04:18 -0600

morphogencc gravatar image

updated 2015-07-27 14:05:12 -0600

Hey all,

I'm running OpenCV 2.4.11 on Windows 7, compiling with Visual Studio 2015.

I've found that during several function calls (to Stitcher::Stich and cv::findContours, for example), there is a critical memory error that causes the program to crash consistently.

For these errors, I get an error like the following in visual studio:

Debug Assertion Failed!

Program: ...a\code\my-project\software\Debug\my-project.exe
File: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xmemory0
Line: 116

Expression: "reinterpret_cast<uintptr_t *>(_Ptr_ptr)[-1] == _BIG_ALLOCATION_SENTINEL" && 0

When I follow the call stack to find out where the crash happened, it always happens at the end of a function when local variables go out of scope. The error is usually on the line:

my-project.exe!std::_Deallocate<cv::Point_<int> >(cv::Point_<int> * _Ptr, unsigned __int64 _Count) Line 114 C++

or similar (I believe when I call Sticher::stitch the crash is for a vector of type cv::DMatch rather than cv::Point).

If I comment out the specific lines (such as cv::findContours), the program runs just fine. In fact, the program works just fine until cv::findContours actually finds a contour; in this case it immediately crashes with the above memory errors.

I've checked that I have the right .dll files, and I do -- I'm wondering if perhaps I need to rebuild OpenCV for Visual Studio 2015? I'm not sure what else would be causing this problem.

thanks!

edit retag flag offensive close merge delete

Comments

1

please double check, if you''re accidentally using any opencv release libs with a debug build, or the other way round

berak gravatar imageberak ( 2015-07-27 14:08:23 -0600 )edit

Just double-checked -- I even removed all of the release .dlls and compiled / ran in Debug to make sure that wasn't the issue, but my program still crashed with the same error.

morphogencc gravatar imagemorphogencc ( 2015-07-27 15:48:29 -0600 )edit

I suggest rebuilding, since findContours is working perfectly fine here :)

StevenPuttemans gravatar imageStevenPuttemans ( 2015-07-28 03:55:26 -0600 )edit

Did you need to rebuild it from source? Are you using VS2015? I've never rebuilt OpenCV from source before, so I'm a bit reluctant to try it -- but I'd also love to have this problem solved :) Hoping the rebuild process goes smoothly!

morphogencc gravatar imagemorphogencc ( 2015-07-28 11:41:15 -0600 )edit
1

I am using Ubuntu and Linux... but I see a lot of people with problems that get solved once they build OpenCV themselves.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-07-29 02:37:52 -0600 )edit
1

I get the same error when using findContours. Did rebuilding solve the problem for you?

DanielT gravatar imageDanielT ( 2015-09-30 05:32:31 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2016-02-10 12:09:35 -0600

For what its worth I think I know a potential cause to this error. Google only showed this very thread for me when I searched for it (or other OpenCV related stuff).

I got the exact same error when I mistakenly tried to compile a program using the VS2013 compiler, but used VS2015-compiled libraries. QtCreator apparently doesn't like VS2015 that much.

edit flag offensive delete link more
0

answered 2015-11-07 02:36:52 -0600

xdata gravatar image

Apparently there's a problem with vectors and OpenCV when compiled with VS2015. Running in Release mode is not a solution, it is a workaround which doesn't work on my environment. Also OpenCV 3.0 (yet) doesn't claim to work within VS2015. Re-compiling OpenCV using VS2015 might help, I was not able to do so and I couldn't find anybody who solved this problem doing so. Apparently this is happens especially (or only) with findContours. Maybee one of the coders of findContours may have a look at it...

Pleeeease!

KR xdata

edit flag offensive delete link more

Comments

Which problem did you not solve?

LBerger gravatar imageLBerger ( 2015-11-07 03:22:36 -0600 )edit

Is this still an issue? If it is a tracked issue in OpenCV, could someone link to the ticket?

dinosaur gravatar imagedinosaur ( 2016-07-19 12:22:19 -0600 )edit

Probably mismatched CRT linking (OpenCV uses dynamic CRT and your app uses static CRT). Related ticket here: https://github.com/opencv/opencv/issu...

byteboon gravatar imagebyteboon ( 2016-08-01 15:19:46 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2015-07-27 14:04:18 -0600

Seen: 5,889 times

Last updated: Feb 10 '16