cv2.imread abort (ubuntu12.04-64, python2.7, opencv2.4.2)

asked 2013-05-25 23:06:11 -0500

tyl12 gravatar image

updated 2013-05-26 03:17:38 -0500

berak gravatar image

Dear, I have met one strange issue with opencv python cv2 functions. presented my testing below.

1> with apt-get install opencv*, all opencv c/c++/python-cv2 functions work well.

2> when I manually re-build opencv2.4.2 (to support cuda), python cv2.imread() will crash but c/c++ interface work well. The crash message is like below:

"terminate called after throwing an instance of 'std::bad_alloc'"

To narrow down, I simplified my config as "cmake -D CMAKE_BUILD_TYPE=DEBUG -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_opencv_python=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=OFF -D WITH_TBB=OFF -D INSTALL_C_EXAMPLES=OFF -D INSTALL_CPP_EXAMPLES=OFF -D WITH_FFMPEG=OFF -D WITH_CUDA=OFF -D WITH_CUBLAS=OFF -D WITH_NVCUVID=OFF .." but such issue still occur. And I have also tried on another ubuntu10.04 server, it doesn't work.

I have also traced the opencv source code by log and python gdb to print bt. The crash point is in file [ modules/highgui/src/grfmt_base.cpp::setSource( const std::string& filename ):::m_filename = filename;]. Gdb stack:


Program received signal SIGABRT, Aborted.
0x00007ffff68e1425 in raise () from /lib/x86_64-linux-gnu/
(gdb) bt
#0  0x00007ffff68e1425 in raise () from /lib/x86_64-linux-gnu/
#1  0x00007ffff68e4b8b in abort () from /lib/x86_64-linux-gnu/
#2  0x00007fffef9d669d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/
#3  0x00007fffef9d4846 in ?? () from /usr/lib/x86_64-linux-gnu/
#4  0x00007fffef9d4873 in std::terminate() () from /usr/lib/x86_64-linux-gnu/
#5  0x00007fffef9d496e in __cxa_throw () from /usr/lib/x86_64-linux-gnu/
#6  0x00007fffef9d4e4d in operator new(unsigned long) () from /usr/lib/x86_64-linux-gnu/
#7  0x00007fffef9bda89 in std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) () from /usr/lib/x86_64-linux-gnu/
#8  0x00007fffef9be7fb in std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned long) () from /usr/lib/x86_64-linux-gnu/
#9  0x00007fffef9befd4 in std::string::assign(std::string const&) () from /usr/lib/x86_64-linux-gnu/
#10 0x00007ffff147908a in cv::BaseImageDecoder::setSource (this=0xf04db0, filename=...) at /home/ylteng/work/share/opencv2.4.2/opencv/modules/highgui/src/grfmt_base.cpp:60
#11 0x00007ffff14527e8 in cv::imread_ (filename=..., flags=1, hdrtype=2, mat=0x7fffffffd640) at /home/ylteng/work/share/opencv2.4.2/opencv/modules/highgui/src/loadsave.cpp:213
#12 0x00007ffff1452bc4 in cv::imread (filename=..., flags=1) at /home/ylteng/work/share/opencv2.4.2/opencv/modules/highgui/src/loadsave.cpp:281
Python Exception <class 'gdb.error'> There is no member named ob_base.:
#13 0x00007ffff2f7087a in pyopencv_imread (args=, kw=0x0) at /home/ylteng/work/share/opencv2.4.2/opencv/rls_debug_nogpu/modules/python/pyopencv_generated_funcs.h:5241
#14 0x0000000000497ea4 in PyEval_EvalFrameEx ()
#15 0x000000000049f1c0 in PyEval_EvalCodeEx ()
#16 0x00000000004a9081 in PyRun_FileExFlags ()
#17 0x00000000004a9311 in PyRun_SimpleFileExFlags ()
#18 0x00000000004aa8bd in Py_Main ()
#19 0x00007ffff68cc76d in __libc_start_main () from /lib/x86_64-linux-gnu/
#20 0x000000000041b9b1 in _start ()


I don't think there is any error in std::string::assign itself. So I guess maybe i have made some mistakes in make configuration or link lib!? I have no idea now and any advise is welcome! Thanks in advance.

edit retag flag offensive close merge delete


Have you tried it in release mode? I didnt use python, but I had the kind of the same problem with VS, and that was what I did to rectify the issue.

rockinfresh gravatar imagerockinfresh ( 2013-08-13 03:21:45 -0500 )edit