GpuMat memory release crashes when declared as global variable (Bug #1235)
Description
When a GpuMat object is declared in global scope, the memory release seems to crash when the app terminates. The crash behavior is not observed when the object is declared locally, in the scope of the main() function.
SYSTEM DESCRIPTION /############################################
OS : Linux/Fedora 15 (64 bit)
Kernel : 2.6.38.8-35.fc15.x86_64
OpenCV SVN revision : 6116 (2011-07-19)
NVIDIA driver version : 275.19
NVIDIA CUDA Toolkit version : 4.0.17
TBB version : 2.2
GCC version : 4.6.0 (NVCC binded to GCC 4.4.6)
SSE & SSE2 : enabled
SOURCE TO REPRODUCE ############################################
#include "opencv2/opencv.hpp"
#include "opencv2/gpu/gpu.hpp"
using namespace cv;
//Global variables
Mat frame;
gpu::GpuMat gframe;
int main() {
//Create an empty frame
frame = Mat::zeros(720,1280,CV_8UC3);
//Upload frame to GPU
gframe = frame;
//Exit and crash
return 0;
}
ERROR ##########################################################
OpenCV Error: Gpu Api call (unspecified driver error) in release, file */OpenCV/modules/gpu/src/matrix_operations.cpp, line 579
terminate called after throwing an instance of 'cv::Exception'
what(): */OpenCV/modules/gpu/src/matrix_operations.cpp:579: error: (-217) unspecified driver error in function release
################################################################
Associated revisions
Merge pull request #1235 from WonderRico:bugfix_dshow
History
Updated by Anatoly Baksheev over 13 years ago
It's known and expected behaviour. Please do no create global or static GpuMat variables.
Explanation:
CUDA Contexts are holded by static variables generated by nvcc. Destruction order of static or global variables is undefined. If CUDA context has been destroyed, any cudaFree function will return error and, as result, CV_Assert will throw exception.
Updated by Anatoly Baksheev over 13 years ago
- Status changed from Open to Done
- (deleted custom field) set to wontfix