cvLoadImage causes segfault in a secondary thread (Bug #596)
Description
I have a function which only loads a number of images (and releases them right after).
When I call the function from the main thread, everything works fine.
Even if I call it 1000+ times (for debug reasons).
As soon as I let the function run in a secondary thread, it will segfault. Sometimes right after the first cvLoadImage call, sometimes after the 2nd or 3rd. But it only happens if I run the function from a secondary thread. Note that the images are not accessd from another thread (so no threading issues on my part).
My platform is WinXP SP3 32Bit. I have downloaded opencv 2.10 and used CMake to make MSYS Makefiles. I used MSYS, GCC44 to build opencv.
I had to download a libvideoInput.a because I wasn't able to link (some issue about libvideoInput.a that it has to be compiled by a previous GCC version: http://tech.groups.yahoo.com/group/OpenCV/message/71043 )
Associated revisions
Merge pull request #596 from ArtanisCV:master
History
Updated by Alexander Shishkov about 13 years ago
- Description changed from I have a function which only loads a number of images (and releases them righ... to I have a function which only loads a number of images (and releases them righ... More
Updated by Alexander Shishkov almost 13 years ago
- Target version deleted ()
Updated by Alexander Shishkov almost 13 years ago
Can't reproduce on trunk. Tried on Linux:
1void* func(void*)
2{
3 for (int i = 0; i < 1000; i++)
4 {
5 Mat a = imread("/home/alex/Desktop/source.png", 1);
6 //imshow("a",a);
7 //char c = waitKey(0);
8 //if (c == 27)
9 // break;
10 cout << i << endl;
11 }
12}
13
14int main(int argc, char * argv[])
15{
16
17 pthread_t thread;
18 pthread_create(&thread, NULL, func, NULL);
19 pthread_join(thread, NULL);
20
21 return 0;
22}
and Windows:
1DWORD ThreadProc (LPVOID lpdwThreadParam )
2{
3 for (int i = 0; i < 1000000; i++)
4 {
5 Mat a = imread("/home/alex/Desktop/source.png", 1);
6 //imshow("a",a);
7 //char c = waitKey(0);
8 //if (c == 27)
9 // break;
10 if (i%1000 == 0)
11 std::cout << i << std::endl;
12 }
13 return 0;
14}
15
16int main(int argc, char * argv[])
17{
18DWORD dwThreadId;
19HANDLE hThread = CreateThread(NULL, //Choose default security
200, //Default stack size
21(LPTHREAD_START_ROUTINE)&ThreadProc,
22//Routine to execute
23(LPVOID) 0, //Thread parameter
240, //Immediately run the thread
25&dwThreadId);
26
27WaitForSingleObject(hThread, INFINITE);
28return 0;
29
30}
- Status changed from Open to Cancelled
- Assignee set to Alexander Shishkov
Updated by Alexander Shishkov almost 13 years ago
- Target version set to 2.4.0