Crash with minimal program example

BlitzMax Forums/BlitzMax Programming/Crash with minimal program example

JoshK(Posted 2008) [#1]
I have come across a very strange bug that can be produced with a minimal program. When the debugger is turned on, the crash occurs at bbsystempoll(). I do not know if this is an OpenGL bug or a BlitzMax one, or some combination of the two. It seems odd that I would be able to use uniform buffers successfully, yet produce a crash under such specific circumstances. The bug has been reported on the OpenGL and NVidia developer forums as well. I do not expect Mark to debug OpenGL programming for me. However, it is possible this is caused by something in the BlitzMax graphics window code, though I think it is an NVidia driver error.

I use a uniform buffer for GPU instancing. I have been using this technique successfully for six months. However, I have found two situation which will cause my program to crash. I was able to reproduce these crashes in a minimal program.

Crash 1
If I detach the uniform buffer from all shaders before ending the program, everything is fine. If I do not delete or detach the buffer, my program freezes. This is bad, but it can be worked around. The bug I am really worried about is...

Crash 2
If I create a full-screen window, create uniform buffer, attach it to a shader, enable the shader, update the uniform buffer data, and draw a single triangle, the program will crash if the user alt-tabs or hits the windows key to go back to the desktop. All of these conditions much be met to produce the crash. For example if I do all of the above, but do not update the uniform buffer data, no crash occurs.

Again, I have been using GPU instancing successfully for some time. If I was doing something fundamentally wrong, I think GPU instancing would probably not work.

You can download my example here. The code is BlitzMax, but if you just open the .bmx files in notepad it will be very easy to see the commands I am using:
http://www.leadwerks.com/post/crash.zip

Here is the required leadwerks.glewex.mod:
http://www.leadwerks.com/post/leadwerks.glewex.mod.zip

This will only work on an SM 4.0 GPU.