Pure virtual method called (Bug #3355)


Added by Philippe FOUBERT over 11 years ago. Updated over 9 years ago.


Status:Done Start date:2013-11-01
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:core
Target version:-
Affected version:branch 'master' (3.0-dev) Operating System:Windows
Difficulty: HW Platform:x86
Pull request:

Description

Since the merge of the upstream master branch, i got some "pure virtual method called" exceptions in my project (which i hadn't before).

The problem appeared between my merge (which is the current one available on the master branch of my git: https://github.com/philippefoubert/opencv.git) done on 25/10/2013 (Parents: f737651071376b7d08524bea4720a4ed683da34d (Merge branch 'master' of https://github.com/Itseez/opencv.git)
+ 7e1ded0ebd98cc5c735cc2d1869b5acb83c50a9c (Merge pull request #1664 from SpecLad:merge-2.4)) and the current one I did on my local repository on 29/10/2013 (Parents: 6ff0db1c7856f52a154fd081dbbd332f8f515aad (Merge branch 'master' of https://github.com/Itseez/opencv.git) + 03bbee327b44c9384f46a042585bc4f0a46d8a26 (Merge pull request #1486 from nzjrs:cv2-logpolar) )

I have added the following function in my MinGW project to find its origin througth a breakpoint using the debugger:

#include <iostream>
extern "C" void __cxa_pure_virtual(void)
{
   std::cout << "__cxa_pure_virtual: pure virtual method called" << std::endl << std::flush;
}

The problem comes from mat.inl.hpp:

inline void Mat::release()
{
    if( u && CV_XADD(&u->refcount, -1) == 1 )
        deallocate();
    [...]
}

when the deallocate() method is called.

My feeling is that it may be linked to the evolutions done when adding the UMat class. I am using the Matx template: i am not very friendly with all the conversions done betwwen Mat, Matx, _InputOutputArray,... it may be linked but i am not sure.

Regards,
Philippe.


Related issues

related to Bug #3450: Intermittent crashes caused by DLL unload issues in ocl m... Open 2013-12-20
related to Bug #4403: “R6025 pure virtual function call” with the pre-built sta... New 2015-06-12

Associated revisions

Revision 54b59c3c
Added by Alexander Alekhin over 10 years ago

Merge pull request #3355 from ElenaGvozdeva:predictOptimalVectorWidth

History

Updated by Philippe FOUBERT over 11 years ago

It has nothing to do with Matx. The exception only appends when we are using a global variable my_matrix declared as:

static Mat my_matrix;

when we leave the application.

Updated by Dinar Ahmatnurov over 11 years ago

Roman, please have a look

  • Description changed from Since the merge of the upstream master branch, i got some *"pure virtua... to Since the merge of the upstream master branch, i got some *"pure virtual... More
  • Assignee changed from Vadim Pisarevsky to Roman Donchenko
  • Status changed from New to Open

Updated by Roman Donchenko over 11 years ago

UMat is Vadim's thing, so I'd rather have him look at it.

That said, Philippe, if you could post a small sample reproducing the problem, it would be rather helpful.

  • Assignee changed from Roman Donchenko to Vadim Pisarevsky

Updated by Vadim Pisarevsky almost 10 years ago

ok, without a sample and considering how often we use Mat I consider this bug as non-reproduceable.

  • Status changed from Open to Cancelled

Updated by wqvbjhc chen almost 10 years ago

it reproduce again. When has a static Mat or Global Mat.
opencv ver:3.0.0, static lib
OS:win7 32bit
IDE: vs2010

sample code is as follow
/*
  • create_mask.cpp *
  • Author:
  • Siddharth Kherada <siddharthkherada27[at]gmail[dot]com> *
  • This tutorial demonstrates how to make mask image (black and white).
  • The program takes as input a source image and ouputs its corresponding
  • mask image.
    */

#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/core.hpp"
#include <iostream>
#include <stdlib.h>

using namespace std;
using namespace cv;

Mat img0, img1, res1, final;

Point point;
int drag = 0;

int numpts = 100;
Point* pts = new Point100;

int var = 0;
int flag = 0;
int flag1 = 0;

int minx,miny,maxx,maxy,lenx,leny;

int channel;

void mouseHandler(int, int, int, int, void*);

void mouseHandler(int event, int x, int y, int, void*) {

if (event  EVENT_LBUTTONDOWN && !drag)
{
if(flag1 0) {
if(var==0)
img1 = img0.clone();
point = Point(x, y);
circle(img1,point,2,Scalar(0, 0, 255),-1, 8, 0);
pts[var] = point;
var++;
drag = 1;
if(var>1)
line(img1,pts[var-2], point, Scalar(0, 0, 255), 2, 8, 0);
imshow("Source", img1);
}
}
if (event == EVENT_LBUTTONUP && drag)
{
imshow("Source", img1); {
flag1 = 1;
img1 = img0.clone();
for(int i = var; i < numpts ; i++)
pts[i] = point;
if(var!=0)
{
const Point* pts3[1] = {&pts[0]};
polylines( img1, pts3, &numpts,1, 1, Scalar(0,0,0), 2, 8, 0);
}
for(int i=0;i&lt;var;i++)
{
minx = min(minx,pts[i].x);
maxx = max(maxx,pts[i].x);
miny = min(miny,pts[i].y);
maxy = max(maxy,pts[i].y);
}
lenx = maxx - minx;
leny = maxy - miny;
imshow("Source", img1);
}
if (event == EVENT_RBUTTONUP)
{
flag = var;
final = Mat::zeros(img0.size(),CV_8UC3);
res1 = Mat::zeros(img0.size(),CV_8UC1);
const Point* pts4[1] = {&pts[0]};
fillPoly(res1, pts4,&numpts, 1, Scalar(255, 255, 255), 8, 0);
bitwise_and(img0, img0, final,res1);
imshow("mask",res1);
imwrite("mask.png",res1);
imshow("Source", img1);
}
if (event == EVENT_MBUTTONDOWN) {
for(int i = 0; i < numpts ; i++) {
pts[i].x=0;
pts[i].y=0;
}
var = 0;
flag1 = 0;
minx = INT_MAX; miny = INT_MAX; maxx = INT_MIN; maxy = INT_MIN;
imshow("Source", img0);
drag = 0;
}
}

int main(int argc, char **argv) {

if(argc != 2)
{
cout << "usage: " << argv[0] << " &lt;input_image&gt;" << endl;
exit(1);
}
Mat src = imread(argv[1]);
minx = INT_MAX; miny = INT_MAX; maxx = INT_MIN; maxy = INT_MIN;
img0 = src;
channel = img0.channels();
res1 = Mat::zeros(img0.size(),CV_8UC1);
final = Mat::zeros(img0.size(),CV_8UC3);
//////////// source image ///////////////////
namedWindow("Source", 1);
setMouseCallback("Source", mouseHandler, NULL);
imshow("Source", img0);
waitKey(0);
img0.release();
img1.release();
}
  • Status changed from Cancelled to Open

Updated by wqvbjhc chen almost 10 years ago

I found the problem, in
MatAllocator* Mat::getStdAllocator() {
static StdMatAllocator allocator;//it's static. but mat's destructor need it. so when that's have a static or global mat, can not be guaranteed this allocator's destructor after that static or global mat.
return allocator;
}

Updated by Alexander Alekhin over 9 years ago

  • Status changed from Open to Done

Also available in: Atom PDF