Hi all,

I have developed a kind of TCP/IP server in Windows CE.NET 4.2. No we are
running "stress" tests over the platform just to assure the correct working
of the device. However, during these tests, I have recently faced the
following exception in my system:

[PID:a7a4bb7a TID:c772ccda 0x879c1800]

NK Kernel: DEBUGCHK failed in file
d:\mckendric\private\winceos\coreos\nk\kernel\nknormal\..\schedule.c at line
316
Exception 00e Thread=879c1800 Proc=a7a4bb7a 'gwes.exe'
AKY=00000211 PC=802415af ESP=143bfa44 EA=00000088

I was connected to the device via Platform Builder using the Ethernet port
of the device. So I could see the "Call Stack" that had lead to the
exception. The problem is that it seemed that the exception had been
originated by a call to PeekMessage() function.

> My program creates a pair of threads for each connection that receives.
> The test is constantly creating and closing connections.
> The source code for each client thread is as follows:

DWORD WINAPI ConnectionThreadPseudoCode ( LPVOID pParms )
{
MSG stMsg;
PeekMessage ( &stMsg, (HWND) INVALID_HANDLE_VALUE, 0, 0,
PM_NOREMOVE );

//
// Rest of the thread body
//

}

> I just call PeekMessage() at the beginning of the thread's execution, to
create the thread's message queue.

The source code of the exception part in schedule.c is the following:

void AddHandleToList (HANDLE *phList, HANDLE hObj, DWORD dwType)
{
[...]

EnterCriticalSection (&NameCS);

if (lpe->hNext = *phList) {
LPEVENT lpeNext = (LPEVENT) GetObjectPtrByType (lpe->hNext, dwType);
DEBUGCHK (lpeNext); <--- this is the line that gives me the
exception in NK
lpeNext->hPrev = hObj;
}

*phList = hObj;

LeaveCriticalSection (&NameCS);
}

Any suggestions on this problem?

Best regards,

R.B.C.