[solved]Runtime Error at end of program - "pure virtual method called"

asked 2014-01-10 02:58:18 -0500

Prasanna gravatar image

updated 2014-01-10 04:16:12 -0500


I think I got the problem solved. It was due to a destructor of a Global Mat being called after the program ends. Its funny that this should happen. I donno whether to call this a bug or not. I released it just before the return statement of main function and things are fine.

PS: If you want to replicate error, try using a Global Mat with just a simple "imread - imshow - waitKey " program.


Actual Question

I was running some OpenCV (3.0.0) codes today. I stumbled upon the following runtime error.

pure virtual method called

terminate called without an active exception

Aborted (core dumped)

This is my gdb backtrace.

(gdb) bt
0  0x00007ffff615bf77 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56

1  0x00007ffff615f5e8 in __GI_abort () at abort.c:90

2  0x00007ffff67636e5 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-
3  0x00007ffff6761856 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6

4  0x00007ffff6761883 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6

5  0x00007ffff676235f in __cxa_pure_virtual () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6

6  0x00007ffff74d5d8c in cv::Mat::deallocate() () from /usr/local/lib/libopencv_core.so.3.0

7  0x0000000000405fdb in cv::Mat::release() ()

8  0x0000000000405d40 in cv::Mat::~Mat() ()

9  0x00007ffff6161071 in __run_exit_handlers (status=1, listp=0x7ffff64e66a8 <__exit_funcs>,   run_list_atexit=run_list_atexit@entry=true) at exit.c:77

10 0x00007ffff61610f5 in __GI_exit (status=<optimized out>) at exit.c:99

11 0x00007ffff6146dec in __libc_start_main (main=0x405451 < main >, argc=2, ubp_av=0x7fffffffe048, 
init= < optimized out > , fini= < optimized out >, rtld_fini = < optimized out >, stack_end=0x7fffffffe038) at libc-start.c:294

12 0x0000000000402f49 in _start ()

When I did some searching around, people pointed out some deallocation / access after lifetime and some were about threads. But I didnt get head or tail of it.

It would be nice if someone could give an explanation.

edit retag flag offensive close merge delete