GLException, or, Jogl masking my bad code

Exhibit A:

net.java.games.jogl.GLException: Error freeing OpenGL context
      at net.java.games.jogl.impl.windows.WindowsGLContext.free(WindowsGLContext.java:129)
      at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.free(WindowsOnscreenGLContext.java:129)
      at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:194)
      at net.java.games.jogl.GLCanvas.display(GLCanvas.java:75)
      at net.java.games.jogl.Animator$1.run(Animator.java:87)
      at java.lang.Thread.run(Thread.java:536)

Not a very pretty error message, and one that had me very confused for quite a while. Even more odd because the only code i changed was pretty much removed from being able to cause this kind of errors.
Eventually, after much cursing, i tracked it down to a glColor4f call, which when commented out worked fine, yet adding it threw the above error on sporadic occasions.

So, have a look at this:


Colour4f col = null;
gl.glColor4f(colour.red, colour.green, colour.blue, colour.alpha);

This was what was happening by accident, yet instead of throwing a NullPointerException which would have pointed me in the correct direction, i get the earlier mentioned exception. I can only assume that i have stepped into a whopping great big try…catch by using the Animator class, which is mistakenly catching my null pointer, and rethrowing it as something mutated and wrong >:(

Can anyone give a more complete explanation? Better yet, is it possible to get this behaviour changed?

Thanks.

OK, this is happening because of the try/finally structure in GLContext.invokeGL(), not the Animator. The RuntimeException is being rethrown in the catch block, but the free() call, which is apparently causing another exception to be thrown, is apparently overriding the NullPointerException. Sorry – please file a bug and I’ll look at this next week.

I’m going to bump this yet again, since I’ve just hit the same problem again (and i’m using an up-to-date nightly build). Seems that this hasn’t been addressed several months later, the issue is still in ‘started’. >:( >:(

Its not too much of a problem for me since I managed to spot the exception as being a blatent lie, but for someone whos not seen it before it just looks like a huge bug inside of Jogl, not their own code :o

hehe … quite funny … just having the same problem here with an empty color object … thanx for the help !

Back when I looked at this I wasn’t able to reproduce the problem, though I realize that there is one. Could you please attach a test case to issue 22? Thanks.

hmm… it should be crimminally easy to reproduce - just throw a null pointer exception from within the rendering call from an Animator. I’ll have a look into reproducing it in something like the gears demo.

Edit: Actually, it doesn’t want to reproduce itself in the gears example. And I’ve since fixed the original bug so I can’t use that (even if it wasn’t embedded deep in my app). I’ll swear blind it still exists though… :-[

It doesn’t reproduce as easily as throwing an exception in the GLEventListener’s display() method. That was how I tried to reproduce it at the time. Apparently something has to be corrupted in the OpenGL state so that freeing the context fails. If at all possible I’d like to have a test case before making changes to the code.

I came across this error as well, but in my case the underlying exception was an ArrayOutOfBoundsException.

My code is kind of poor as I’m still new to OpenGL, but I saved my errant code if you’d like to take a look. The error is quite reproducable.

-sungwon

Pretty much any exception that can go uncaught long enough to halt a JVM is going to do this, nullpointer exceptions, out of index exceptions, and my personal favorite stringtokenizer exceptions… I’m guessing jogl has a catch exception or catch throwable that causes the problem. Should be able to hit this problem with the below code

int[] stupid = new int[1];
stupid[10] = 1;

I’m using the original jogl release and not a nightly build so I can’t test to see if this is enough to cause the problem in a more current build.

For what it’s worth I’ve just hit this myself using a port of NeHe #25. When I tried to display my own objects a NullPointerException in my Renderer#drawGLScene() started me down a trail that lead to this thread ( god I love this site ). I am using the latest release of JOGL.

throwing a try catch around the guts of my drawGLScene pointed me to my actual error.