Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi, dear all:

I have a worker thread which have a window in it. The thread proc like:

unsigned __stdcall ThreadFunc( void *param )
{
	MyWindow myWin;
	MSG msg;
	BOOL bRet;
	while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
	{
		if (bRet == -1)
		{
			// handle the error and possibly exit
		}
		else
		{
			TranslateMessage(&msg); 
			DispatchMessage(&msg); 
		}
	} 
	return (int) msg.wParam;
}

MyWindow is derived from CWindowImpl. Now my problem is that this program crashed in DispachMessage randomly as shown in minidump in crash reports.

What could be the problem?
Posted

Most likely the crash is in a deeper function. The debugger show it in your DispatchMessage function, because it is the nearest one with source code available.

Is the C++ debugger capable of showing all stack trace entries, not just the ones that you have source code for?

This could help in detecting the real issue.

Cheers
Uwe
 
Share this answer
 
Yes, I got the all stack trace when I use windbg open the minidump, like below:
00 1a14f398 76cd86ef 0xfdf920e
01 1a14f3c4 76cd8876 user32+0x186ef
02 1a14f43c 76cd70f4 user32+0x18876
03 1a14f498 76cccea0 user32+0x170f4
04 1a14fcc8 771d647e user32+0xcea0
05 1a14fd34 21725f86 ntdll+0x4647e
06 1a14ff38 1a14ff20 RJCK!ThreadFunc+0xb6
or like :
00 1a14f398 76cd86ef 0xfdf920e
01 1a14f3c4 76cd8876 user32!InternalCallWinProc+0x23
02 1a14f43c 76cd70f4 user32!UserCallWinProcCheckWow+0x14b
03 1a14f498 76cccea0 user32!DispatchClientMessage+0xda
04 1a14fcc8 771d647e user32!__fnOUTSTRING+0x63
05 1a14fcd0 00000000 ntdll!KiUserCallbackDispatcher+0x2e
And the msg is common, like WM_TIMER and so on. It's wired. I think the reason is Window class destroyed before all msg in loop has handled at first. But GetMessage will return -1 when the handle is invalid. Now I think the stack maybe destoyed in some window proc, then when it crash when it return. Or maybe my win proc is destroy by other code, is it possible?
 
Share this answer
 
Comments
Uwe Keim 5-Dec-10 13:57pm    
You could somehow get symbols for the system DLLs from Microsoft (I do not remember how), so your stack trace looks more readable.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900