PDA

View Full Version : Program Crash



draftomatic
03-18-2009, 09:27 AM
So I have a program in OpenGL that works on several computers, but when I try to compile it (or run the exe) on one of my desktops I get an access violation exception and VC++ breaks at this line, which lives inside my main loop in WinMain:

if (GetAsyncKeyState(VK_ESCAPE))
shutdown();

If I comment these lines (which are relatively unimportant), an access violation occurs at the very next line. If I comment that line, it crashes on the next, etc etc.

This is particularly troubling because it works fine on another desktop which has the same processor and GPU (AMD Phenom 9950 and ATI Radeon 4850). I've also tried several other OpenGL programs, including a few using GLUT to handle the Windows interfacing, and they all crash. Copying the compiled exe also causes runtime access violation.

My drivers are up-to-date. Running Vista 64bit Ultimate. The program works on another PC with Vista 64bit Home and one with XP 32bit.

Anyone have an idea what could be causing this? I can give more details if needed.

_NK47
03-19-2009, 10:37 AM
do you do some overclocking? seems cpu/gpu is not that stable on your desktop pc. can't explain why otherwise it runs well on others whereas any GL program crashes on yours. keep in mind that particullary graphics apps tend to heat it up.

draftomatic
03-19-2009, 11:50 AM
I don't overclock.

I do have a slight heat issue which I'm fixing soon with a better cpu heatsink and another chassis fan, but it's not serious. CPU & GPU idle at 50C and max out around 70C when I'm playing an intense game or something.

When I run the program in point the CPU and GPU are at 50C.

Also it's not ANY OGL program, only the ones I write. I can run all kinds of commercial games that utilize ogl.

_NK47
03-20-2009, 02:45 AM
some memory corruption could cause this say something like this:
// global char array
char g_String[16];
// code to corrupt it
sprintf(g_String,"%s.%d","string length is beyond 16 bytes",anyNumber);

debugging and studying the code is the best thing here as noone could tell you for sure.

draftomatic
03-20-2009, 11:06 AM
I was a little confused about what was causing the crash. It seems to be the call to SwapBuffers() inside my loop in WinMain. When I debug step to the call, the value of hdc is this:

0xfe011734 {unused=???}
CXX0030: Error: expression cannot be evaluated

Then I try to make the call and I get this exception:

Unhandled exception at 0x00000000 in Program.exe: 0xC0000005: Acces violation.

I'm not a buff on Windows GUI programming so I'm not sure where to go from here. Anyone see anything?


while (!quit)
{
if (PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE))
{
if (msg.message == WM_QUIT)
quit = true;

TranslateMessage(&msg);
DispatchMessage(&msg);
}

renderFrame(); //draws the scene

SwapBuffers(hdc);

if (GetAsyncKeyState(VK_ESCAPE))
shutdown();

think(); //calculates object positions, etc.
}

draftomatic
03-24-2009, 11:29 AM
Appears to be a driver issue. I installed an old driver (CCC 8.12) and it worked.

However, whenever I restart my computer the problem starts up again, and I have to reinstall the driver to get things to work.

Anyone know what could be happening?