1 | initial version |
Meanwhile I was digging a little bit further into the problem and I really think there is a bug in OpenCV.
In Mat::create the following code is executed
MatAllocator *a = allocator, *a0 = getStdAllocator();
which calls getStdAllocator. This is implemented as:
MatAllocator* Mat::getStdAllocator()
{
static MatAllocator * allocator = new StdMatAllocator();
return allocator;
}
i.e. returning a static local variable. When getStdAllocator() is executed in parallel this may crash (in my case it simply sometimes returns NULL).
I can get my example running by ensuring that the static local variable is initialized first, i.e.
cv::MatAllocator *a0 = cv::Mat::getStdAllocator();
#pragma omp parallel for
for(int i = 0; i < 100; i++)
{
cv::Mat blub;
blub.create(3456, 5184, 16);
cout << ".";
}
But it seems to be fixed here already: http://code.opencv.org/issues/4189