-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Call chain possible problem warnings when calling into cv::remap with a cv::Mat #10651
Description
System information (version)
- OpenCV => 3.4.0
- Operating System / Platform => Ubuntu 17.10
- Compiler => : GCC 7.2.0
Detailed description
Due to how the deferred deallocation queues work / are tracked with UMats, it is possible to get flooded with (what I believe to be) erroneous warning messages:
! OPENCV warning: getUMat()/getMat() call chain possible problem.
! Base object is dead, while nested/derived object is still alive or processed.
! Please check lifetime of UMat/Mat objects!
In particular, I am finding this issue with cv::remap. See code below. I don't think this is just with remap though; it seems like it can happen if an OCL function calls getUMat on a cv::Mat which doesn't outlive the next UMat alloc call after the OCL function finishes and adds itself to the cleanup queue.
This makes it somewhat difficult to diagnose actual aliasing issues. It seems like UMats that just point to cv::Mats could be made to never enter the dealloc queue (I assume the deferment behavior is for performance, but I also sort of assume there isn't really a performance improvement in this case?). If those deallocations happened at the end of the CL call; it would necessarily be before any cv::Mats passed in had a chance to get dtored.
Steps to reproduce
#include <opencv2/opencv.hpp>
int main(int argc, char** argv) {
cv::UMat image(1, 1, CV_8UC3);
cv::UMat next;
for(size_t i = 0;i < 50;i++) {
cv::Mat map(image.size(), CV_32FC2); // Note: Change this to cv::UMat and the warnings stop.
cv::remap(image, next, map, cv::UMat(), cv::INTER_LINEAR, cv::BORDER_CONSTANT, cv::Scalar(0, 0, 0));
}
return 0;
}