Ask Your Question

cv::VideoCapture::open(file) causes fatal memory error

asked 2017-01-18 22:00:33 -0600

akihiko gravatar image

Hello. After upgrading Ubuntu to trusty, a simple video-load code became producing fatal memory error. The code is just opening an video file:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main(int argc, char**argv)
  std::string path="sample/vout2l.avi";
  cv::VideoCapture vin(path);
  return 0;

Executing this causes a fatal memory error:

*** Error in `./cv2-videoread.out': free(): invalid next size (fast): 0x000000000217b590 ***
Abort (core dumped)

I compiled this code with OpenCV 2.4.8 and 2.4.13; both cases finished with the above error.

The backtrace by gdb was:

#0  0x00007fc80d659c37 in raise () from /lib/x86_64-linux-gnu/
#1  0x00007fc80d65d028 in abort () from /lib/x86_64-linux-gnu/
#2  0x00007fc80d6962a4 in ?? () from /lib/x86_64-linux-gnu/
#3  0x00007fc80d6a255e in ?? () from /lib/x86_64-linux-gnu/
#4  0x00007fc80d6a42ef in ?? () from /lib/x86_64-linux-gnu/
#5  0x00007fc80d6a5ba4 in ?? () from /lib/x86_64-linux-gnu/
#6  0x00007fc80d6a77d2 in posix_memalign () from /lib/x86_64-linux-gnu/
#7  0x00007fc8092d10fe in av_malloc () from /usr/lib/x86_64-linux-gnu/
#8  0x00007fc809512708 in ?? () from /usr/lib/x86_64-linux-gnu/
#9  0x00007fc8095139b3 in avio_open2 ()
  from /usr/lib/x86_64-linux-gnu/
#10 0x00007fc8095b69e3 in avformat_open_input ()
  from /usr/lib/x86_64-linux-gnu/
#11 0x00007fc80df30584 in CvCapture_FFMPEG::open(char const*) ()
  from /usr/lib/
#12 0x00007fc80df30719 in cvCreateFileCapture_FFMPEG ()
  from /usr/lib/
#13 0x00007fc80df32ac9 in cvCreateFileCapture_FFMPEG_proxy(char const*) ()
  from /usr/lib/
#14 0x00007fc80df1ad89 in cvCreateFileCapture ()
  from /usr/lib/
#15 0x00007fc80df1b045 in cv::VideoCapture::open(std::string const&) ()
  from /usr/lib/
---Type <return> to continue, or q <return> to quit---
#16 0x00000000004008a2 in main (argc=<optimized out>, argv=<optimized out>)
    at cv2-videoread.cpp:32

It seemed that the issue was caused by libavformat and/or libavutil, so I reinstalled them but it didn't work.

If you have any ideas to fix this issue or investigate more, please let me know. I'm struggling with this issue for these several months.

Many thanks.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-08-09 04:08:17 -0600

akihiko gravatar image

I've solved this issue.

By analyzing the program with ldd, I found that it was linked to, for example, /usr/lib/ However, in x86_64 system, it should be /usr/lib/x86_64-linux-gnu/ In my system, both files were installed.

The issue was caused by /usr/lib/libopencv_*.so (I'm not sure how I installed them. Maybe from source code...?). I removed these files, and compiled the above program again. Then it worked without errors.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-01-18 22:00:33 -0600

Seen: 569 times

Last updated: Aug 09 '17