Search code examples
c++visual-studioopencvcrash

Opencv crashing after random amount of seconds


I'm using opencv's lates version on visual studio with c++. The problem I have is that my program runs perfect and i see the result,however the program crashes with code 1 after random number of seconds (sometimes satys longer and sometimes shorter). When I run it with vs debugger Visual studio crashes with my program shortly after my program runs (the code itself is fine and no build error). Has anyone faced this problem before?

I tried reinstalling everything.


Solution

  • I would guess that this crash is related to some kind of memory error. Your programm may accesses memory, which has been freed before, or writes data to locations, where it should not due to pointers to invalid locations.

    To check for these kind of errors, build your project (and OpenCV) with debug symbols. Then execute your app with a tool like valgrind (linux) or DrMemory (https://drmemory.org/). This should report where these errors occur. (You might need to adapt the stack trace size, if the error appears deep inside a library. See the documentation for this)