I encountered a strange problem while coding a OpenGl program with C++ under Visual Studio Express 2010.
I use: Windows 7 64bit, OpenGl 4.x
My partner uses: Windows XP 32bit, Visual Studio Express 2010, OpenGl 2.x
Until now we just drawed vertexes for our models and it works fine at both systems (I know, I know: deprecated but we're still beginners). Now he included a lib to import 3d-meshes and make an animation. For him everything works fine but I get
First-chance exception at 0x0055f838 in Ant Simulation.exe: 0xC0000005: Access violation reading location 0x00bb0000.
Unhandled exception at 0x0055f838 in Ant Simulation.exe: 0xC0000005: Access violation reading location 0x00bb0000.
With the debugger I traced the problem to the line
glDrawArrays(GL_QUADS,0,n_data);
I tried to catch the code, but nothing is triggered. Strange enough, yesterday I could go over this line 2-3 times with the debugger until it crashed, today it crashes directly. I checked yesterday that n_data is the same every time. If I execute the *.exe in Windows, it crashes (error code below). When my partner sends me his *.exe, it usually doesn't work, but 1 time I could start it. I reproduced the error on an other windows. We tried on Linux 64bit and there is no problem. I tried running it in compatibility mode, but the problem keeps the same (still crashes).
I searched around and found this:
https://blogs.msdn.com/b/debugger/archive/2010/05/12/visual-studio-debugger-fails-to-catch-unhandled-exception-for-a-windows-form-or-wpf-application.aspx?Redirected=true
Not sure if I understood this correctly. There is an exception I cannot catch but which will kill the application - but why haven't other system a problem with this exception?
I tried to solve it the way described in the link but it seems in VS Express I have not the menu to throw the first-chance exceptions. I'll try to get VS 2012 but nevertheless I'd like to know: Is this an enirely Windows thing or could there by a problem with my code which causes the crash (as suggested in one of the comments in the link)? I would also highly appreciate an explication for what is actually going on...
The error I get when I run the *.exe:
Problem Event Name: APPCRASH
Application Name: Ant Simulation.exe
Application Version: 0.0.0.0
Application Timestamp: 511d99a3
Fault Module Name: StackHash_0a9e
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 00000000
Exception Code: c0000005
Exception Offset: 0037f278
OS Version: 6.1.7601.2.1.0.256.48
Locale ID: 1031
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
A "first chance exception" in Windows isn't a C++ exception, it means the runtime system has detected illegal behaviour of your program, such as dereferencing an invalid pointer. In fact, "Access violation reading location 0x00bb0000" suggests very much that this is what's happening.
Dereferencing an invalid pointer doesn't necessarily cause the same behaviour on different systems or even on different runs on the same machine: see questions like C code crashes in Windows, but not in Linux for more information on that. In this case, the fault seems to be occurring inside the GL implementation, but this is probably caused by earlier application code giving it bad information.
Check that all the enabled vertex arrays have at least n_data
elements. (Be particularly careful to make sure they don't have only n_data - 1
elements, and that n_data
holds the value you expected.) You should also check that any pointers you have previously passed to GL functions were valid. There's a lot more GL state to check too, but that would be my first guess.