A breakpoint exception occurs on the "DEBUGCHK(GET_RUNSTATE(pth) != RUNSTATE_RUNNING)" line in the NextThread kernel call in Windows CE .NET 4.2 (891987)



The information in this article applies to:

  • Microsoft Windows CE .NET 4.2

SYMPTOMS

When you run a debug image of Microsoft Windows CE .NET 4.2 that is attached to the debugger, the DebugBreak function causes a breakpoint exception to occur on the following line in the NextThread kernel call:

DEBUGCHK(GET_RUNSTATE(pth) != RUNSTATE_RUNNING)

When this problem occurs, the debug image stops responding or restarts.

Note This problem is unusual and might occur in any context. You cannot verify that this problem is occurring on a retail device that stopped responding or that restarted itself because DEBUGCHK macros only occur on a debug image build.

CAUSE

This problem occurs when an interrupt service thread (IST) calls the WaitForSingleObject function at the same time that the IST owns a critical section. For example, the following code calls the WaitForSingleObject function in a critical section.
DWORD WINAPI InterruptThread(LPVOID lpParameter)
{
	DWORD	dwRet;


	while(1) {
		EnterCriticalSection(&g_CS);
		dwRet=WaitForSingleObject(hIntEvent, /*INFINITE*/IST_TIMOUT);
		if (dwRet == WAIT_TIMEOUT) {
			RETAILMSG(1,(TEXT("WAIT_TIMEOUT\r\n")));
		}
		if (dwRet == WAIT_OBJECT_0) {
			RETAILMSG(1,(TEXT("WAIT_OBJECT_0\r\n")));
		}
		if (dwRet == WAIT_FAILED) {
			RETAILMSG(1,(TEXT("WAIT_FAILED\r\n")));
		}
		InterruptDone(SYSINTR_TIMING);
		LeaveCriticalSection(&g_CS);
	}

	return 0;
}

RESOLUTION

To resolve this problem, use one of the following methods:
  • Modify the code so that the IST does not own a critical section when the IST calls the WaitForSingleObject function.
  • Modify the thread priority of the IST.

MORE INFORMATION

For more information about kernel scheduling and threads in Windows CE .NET 4.2, visit the following Microsoft Developer Network (MSDN) Web site:

Modification Type:MajorLast Reviewed:8/18/2005
Keywords:kbnofix kbtshoot kbprb KB891987 kbAudDeveloper