Access violation in sample program

Access violation in sample program

I get an access violation in my program in a part that was copied from the sample program Puzzle (...SamplesOpenGLPuzzle). It appears that the error also exist in the sample program. Is this error specific in my environment (CVF6.5A in Windows 95) or does this error happen for others too?
The error is normally not a problem, because the exception status for access violation is "stop if not handled", but apparently it is handled and it goes on without problem. But when you debug the program you see the access violation in the output window and when the exception is set to "stop always" it stops at a position where I do not see any problem.
Sometimes the program stops when calling SetDCPixelFormat in the Wndproc and sometimes it stops when performing a rotation via the key F1, F2 or F3.

My question is: do others experience the same error?

Though the program does not encounter further problems, I assume something is not set good. An access violation should not occur, handled or not handled.


7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

There may be a problem with the OpenGL implementation for Windows 95. I have run this example on Windows 95, 98, NT and 2000 and had no trouble. Do you see an error when this is not run in the debugger?

I have worked on this example a lot, and never saw an access violation.


Retired 12/31/2016

I don't see an error when I run the sample in the release mode. It is only visible in debug mode as well in the sample program (in ..SamplesAdvancedOpenGLPuzzle) as in my own program.
I just try it again and I found, that the access violation only occurs when running the program via "Start debug" and "Go" and only after pressing F2 several (6) times. It does not appear when executing the debug version of puzzle.exe directly.

I can't reproduce this on my Windows 2000 system.


Retired 12/31/2016

You might read the Microsoft Knowledge Base article Q240896, OpenGL Program May Cause an Invalid Page Fault Error Message if the Window Is Moved or Resized (click here to view Q240896).


Oh, I recognize this problem. The access violation is an array out of bounds.
You can force it to happen if you compile with a check for array out of bounds and run it after going to your control panel and changing the settings on your
display to a color palette of 256 colors. The routine does a malloc to allocate the storage for the array(palettte%palPalEntry), but it is declared with only 1 element.

I see what you mean, but in my case the flag PFD_NEED_PALETTE is not set and so the code for the palette structure is skipped.
This time the error occurs in the routine SetPixelFormat, but in the Puzzle-example it also happens on other points in the program.


Leave a Comment

Please sign in to add a comment. Not a member? Join today