Unhandled exception (msvcr120.dll) using imwrite()
I'm developing a software that has a few threads writing 10 to 50 bitmap files per second and sometimes I'm getting this exception.Each thread writes its bitmap files into different folders.
I tried cloning the cv::Mat just before imwrite(), or getting a lock before calling imwrite() but those didn't help.
Each threads uses this code to write bitmap files.
cv::Mat source_image; // UINT8, 1x128x130
// do some processing to the source_image;
cv::Mat cloned_image = source_image.clone();
if ((cloned_image.rows > 0) && (cloned_image.cols >0)) {
cv::String file_name = ""; // somewhere
cv::imwrite(file_name, cloned_image); // THIS IS WHERE I GET THE EXCEPTION
}
I also checked the mini dump file (*.dmp) and the exception code was 0xC0000409.
Here is the stack info from the mini dump file.
msvcr120.dll!_invoke_watson(const wchar_t * pszExpression, const wchar_t * pszFunction, const wchar_t * pszFile, unsigned int nLine, unsigned __int64 pReserved) Line 132 C++
msvcr120.dll!_invalid_parameter(const wchar_t * pszExpression, const wchar_t * pszFunction, const wchar_t * pszFile, unsigned int nLine, unsigned __int64 pReserved) Line 85 C++
msvcr120.dll!_invalid_parameter_noinfo() Line 97 C++
msvcr120.dll!_write(int fh, const void * buf, unsigned int cnt) Line 66 C
msvcr120.dll!_fwrite_nolock(const void * buffer, unsigned __int64 size, unsigned __int64 num, _iobuf * stream) Line 166 C
msvcr120.dll!fwrite(const void * buffer, unsigned __int64 size, unsigned __int64 count, _iobuf * stream) Line 83 C
opencv_world300.dll!00007ffc0e265373() unknown
opencv_world300.dll!00007ffc0e264745() unknown
opencv_world300.dll!00007ffc0e256899() unknown
opencv_world300.dll!00007ffc0e2532bb() unknown
opencv_world300.dll!00007ffc0e252f36() unknown
cv::imwrite(file_name, cloned_image);
Thank you.
do you share any variable accross your program's threads?
Hi, urres_coding! No shared variables across the threads.
Googling shows that the code might imply stack overflow, but also pethaps running out of consecutive memory. So the problem might not be in threads as such or a local issue, but in general memory managent of how you handle the large number of images. And in C or C++ the problem might be anywhere...
whether is the source image is empty before write?
Hi, mvuori! I also googled and got results about stack overflow, but as my machine has a large free space of memory I excluded that possibility...
Hi, StefanCheung! I'm cloning the source image and checking the cloned image's size before calling cv::imwrite, so I don't think that the image is empty.
oh my, do you know, how old that is ?
Hi, berak! Well, I do know that is old, but I cannot update the library unless it's going to solve the very problem I'm dealing with...