Microsoft KB Archive/891987

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

Article ID: 891987

Article Last Modified on 3/14/2007

-

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(&quot;WAIT_TIMEOUT\r\n&quot;))); }       if (dwRet == WAIT_OBJECT_0) { RETAILMSG(1,(TEXT(&quot;WAIT_OBJECT_0\r\n&quot;))); }       if (dwRet == WAIT_FAILED) { RETAILMSG(1,(TEXT(&quot;WAIT_FAILED\r\n&quot;))); }       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:

http://msdn2.microsoft.com/en-us/library/ms918465.aspx

Keywords: kbnofix kbtshoot kbprb KB891987

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.