Unhandled exception when ending a program

H

Hilary Zhang

When I try to end my program, which is written in VC++6.0 and runs on WinXP,
I get an error message "Unhandled exception with my.exe (NTDLL.DLL). Access
violation." My code is like this:
case WM_DESTROY:
{
// tell the rendering loop to terminate itself
EnterCriticalSection(&csThreadSafe);
rsRenderData.bTerminate = TRUE;
rsRenderData.bModifyFlag = TRUE;
LeaveCriticalSection(&csThreadSafe);

WaitForSingleObject(hThreadHandle, 5000);

DeleteCriticalSection(&csThreadSafe);

delete pScene;

glDeleteLists(nFontList, 128);

// shut down OpenGL Rendering context
wglMakeCurrent(hDC, 0);
wglDeleteContext(hRC);

ReleaseDC(hWnd, hDC);
PostQuitMessage(0);
}

Can anyone give me some suggestion what might be the problem? Thanks.
 
J

John Harrison

Hilary Zhang said:
When I try to end my program, which is written in VC++6.0 and runs on WinXP,
I get an error message "Unhandled exception with my.exe (NTDLL.DLL). Access
violation." My code is like this:
case WM_DESTROY:

[windows code snipped]
Can anyone give me some suggestion what might be the problem? Thanks.

No, not nearly enough information. In any case this is a C++ group not a
windows programming group.

I suggest that you try a debugger, if that doesn't help then try removing
code until you eliminate the problem, that should give you a clue as to
which line is causing the problem. If you are still stuck ask in a Windows
programming group such as comp.os.ms-windows.programmer.win32.

john
 
M

Mike Wahler

Hilary Zhang said:
When I try to end my program, which is written in VC++6.0 and runs on WinXP,
I get an error message "Unhandled exception with my.exe (NTDLL.DLL). Access
violation." My code is like this:
case WM_DESTROY:
{
// tell the rendering loop to terminate itself
EnterCriticalSection(&csThreadSafe);
rsRenderData.bTerminate = TRUE;
rsRenderData.bModifyFlag = TRUE;
LeaveCriticalSection(&csThreadSafe);

WaitForSingleObject(hThreadHandle, 5000);

DeleteCriticalSection(&csThreadSafe);

delete pScene;

glDeleteLists(nFontList, 128);

// shut down OpenGL Rendering context
wglMakeCurrent(hDC, 0);
wglDeleteContext(hRC);

ReleaseDC(hWnd, hDC);
PostQuitMessage(0);
}

Can anyone give me some suggestion what might be the problem? Thanks.

The first problem is that you're asking about this in the wrong place.
We only discuss ISO standard C++ here, as indicated in:
http://www.slack.net/~shiva/welcome.txt

The place to ask about Windows programming issues is newsgroup
comp.os.ms-windows.programmer.win32

If it turns out the problem is with the OpenGL stuff, try:
comp.graphics.api.opengl


-Mike
 
Joined
Oct 8, 2008
Messages
1
Reaction score
0
hi guy.., i got ur question and i got the answer
as i faced the same access violation problem
at EnetrCriticalSection(&urobject)

u created object its nice but .., u did EnterCriticalSection(&urobject);
without initialising the object for the critical section
u have to do InitializeCriticalSection(&urObject);
i.e..,
CRITICAL_SECTION urobject;
InitializeCriticalSection(&urObject);
EnterCriticalSection(&urobject);
..............
........


but not
CRITICAL_SECTION urobject;
EnterCriticalSection(&urobject); //without initialising the object we should not use this function otherwise we get unhandled exception accessviolation

as i faced the sameproblem and suffered a lot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top