I'm working on a program, but get stuck up. When I debug, it "sometimes" totally freezes the debugger. I removed everything possible while preserving the problem reproducable. Smallest code doing the same thing is here:
Code:
#include <windows.h>
DWORD WINAPI FileopenThread(PVOID pParam) {
// breakpoint on the following line
return 0;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE h, PSTR szCmdLine, INT nCmdShow) {
MSG msg;
HWND hWnd;
HANDLE hThread;
WNDCLASSEX wcex = {sizeof(WNDCLASSEX), 0, (WNDPROC)DefWindowProc, 0, 0, hInstance, 0, 0, 0, 0, "MyClass", 0};
RegisterClassEx(&wcex);
hWnd = CreateWindowEx(0, "MyClass", "title", 0, 0, 0, 0, 0, 0, 0, hInstance, 0);
ShowWindow(hWnd, nCmdShow), UpdateWindow(hWnd);
// breakpoint on the following line
hThread = CreateThread(0, 0, FileopenThread, "datafile", 0, 0);
CloseHandle(hThread);
while (GetMessage(&msg, 0, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
Compile it in Visual C++ 6 (I also have Service Pack 5) and run debugger. It stops on the lower breakpoint. Press Go (F5) and if it now stops on the higher breakpoint, stop debugging (Shift + F5) and repeat the process (running debugger and so on..) Usually in about three, five times it freezes. I'm desperate, chasing such bug is a torture. Thanks in advance for any help...