Crash in WindowsAWTWGLGraphicsConfigurationFactory

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Crash in WindowsAWTWGLGraphicsConfigurationFactory

Lathanda
opengl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationImpl(WindowsAWTWGLGraphicsConfigurationFactory.java:171

Source from
https://github.com/JogAmp/jogl/blob/master/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java

Sourcecode:
170:               if( 0 > gcIdx ) {
171:                    chosenGC = configs[gcIdx];

The condition ensures that gcIdx is negative. Using a negative index on an array will always crash.

Is there a workaround or a bug fix?

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 1
        at jogamp.fat/jogamp.opengl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationImpl(WindowsAWTWGLGraphicsConfigurationFactory.java:171)
        at jogamp.fat/com.jogamp.nativewindow.GraphicsConfigurationFactory.chooseGraphicsConfiguration(GraphicsConfigurationFactory.java:424)
        at jogamp.fat/com.jogamp.opengl.awt.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:1513)
        at jogamp.fat/com.jogamp.opengl.awt.GLCanvas.addNotify(GLCanvas.java:609)
        at java.desktop/java.awt.Container.addNotify(Container.java:2800)
        at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4783)
        at java.desktop/java.awt.Container.addNotify(Container.java:2800)
        at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4783)
        at java.desktop/java.awt.Container.addNotify(Container.java:2800)
        at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4783)
        at java.desktop/javax.swing.JRootPane.addNotify(JRootPane.java:729)
        at java.desktop/java.awt.Container.addNotify(Container.java:2800)
        at java.desktop/java.awt.Window.addNotify(Window.java:778)
        at java.desktop/java.awt.Frame.addNotify(Frame.java:490)
        at java.desktop/java.awt.Window.pack(Window.java:816)
Reply | Threaded
Open this post in threaded view
|

Re: Crash in WindowsAWTWGLGraphicsConfigurationFactory

Sven Gothel
Administrator
On 6/14/20 3:21 PM, Lathanda [via jogamp] wrote:

> opengl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationImpl(WindowsAWTWGLGraphicsConfigurationFactory.java:171
>
>
> Source from
> https://github.com/JogAmp/jogl/blob/master/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
>
> Sourcecode:
> 170:               if( 0 > gcIdx ) {
> 171:                    chosenGC = configs[gcIdx];
>
> The condition ensures that gcIdx is negative. Using a negative index on an
> array will always crash.
>
Good catch, thank you.

This typo was introduced with my commit:

commit 0a6a592c04a85d8124aa9d38b67f0caa1d739b75
Date:   Fri Dec 10 05:24:32 2010 +0100

now fixed via commit

commit d335d99df25cc929d06765c3f1af3944f124f6a7
Date:   Mon Jun 15 01:21:44 2020 +0200

    Fix 'typo' in branching, valid config index is >= 0 (not < 0)

    This issue was introduced in commit 0a6a592c04a85d8124aa9d38b67f0caa1d739b75
    and the '2nd choice branch' obviously never tested.

    Thanks to Lathanda finding this issue on 6/14/20.


---
a/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
+++
b/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
@@ -167,7 +167,7 @@ public class WindowsAWTWGLGraphicsConfigurationFactory
extends GLGraphicsConfigu
                 }
                 winConfig.preselectGraphicsConfiguration(drawableFactory,
pfdIDs);
                 final int gcIdx =
pfdIDOSet.indexOf(Integer.valueOf(winConfig.getPixelFormatID()));
-                if( 0 > gcIdx ) {
+                if( 0 <= gcIdx ) {
                     chosenGC = configs[gcIdx];
                     if(DEBUG) {

System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: Found matching
AWT PFD ID "+winConfig.getPixelFormatID()+" -> "+winConfig);

~Sven


signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Crash in WindowsAWTWGLGraphicsConfigurationFactory

gouessej
Administrator
In reply to this post by Lathanda
Yes, Runiter found that one too. However, please use the correct --add-open clauses to make it work or you'll just get a GLException later.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Crash in WindowsAWTWGLGraphicsConfigurationFactory

Lathanda
I'm using --add-open, but it doesn't help.
I did analyse the code in hope to find a solution. I try to make jogamp work under openjdk11,13 or 14, but i wasn't yet able to do it. As i plan to switch my project from jdk1.8 to openjdk14, I really search for a solution for the modular problem, as i want to avoid to replace the well tested jogamp gl code, with new untested lwjgl code.
atm I don't see a way to get jogamp working with modules.
Reply | Threaded
Open this post in threaded view
|

Re: Crash in WindowsAWTWGLGraphicsConfigurationFactory

Sven Gothel
Administrator
On 6/16/20 5:19 PM, Lathanda [via jogamp] wrote:
> I'm using --add-open, but it doesn't help.
> I did analyse the code in hope to find a solution. I try to make jogamp work
> under openjdk11,13 or 14, but i wasn't yet able to do it. As i plan to switch
> my project from jdk1.8 to openjdk14, I really search for a solution for the
> modular problem, as i want to avoid to replace the well testet jogamp gl code,
> with new untested lwjgl code.
> atm I don't see a way to get jogamp working with modules.

So this is a strict blocking point using JogAmp w/ OpenJDK 14?
No way around using old fashion classpath?

If this is so, we surely need to resolve it.
Is this the case?

~Sven
Reply | Threaded
Open this post in threaded view
|

Re: Crash in WindowsAWTWGLGraphicsConfigurationFactory

Sven Gothel
Administrator
In reply to this post by gouessej
On 6/15/20 5:43 PM, gouessej [via jogamp] wrote:
> Yes, Runiter found that one too. However, please use the correct --add-open
> clauses to make it work or you'll just get a GLException later.

You, Julien, and another person at least made good success here.
Julien also has a test case on his website right?

Now, is that sufficient for OpenJDK 14 and Runiter, Lathanda etc use cases?
Hmm.

~Sven
Reply | Threaded
Open this post in threaded view
|

Re: Crash in WindowsAWTWGLGraphicsConfigurationFactory

gouessej
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: Crash in WindowsAWTWGLGraphicsConfigurationFactory

Lathanda
This post was updated on .
In reply to this post by Sven Gothel
I didn't manage to get it working. That doesn't mean it isn't possible.
I tried Openjdk11,13 and 14.

My commandline is

C:\Program Files\Java\jdk-14\bin\javaw.exe --add-exports java.base/java.lang=ALL-UNNAMED --add-exports java.desktop/sun.awt=ALL-UNNAMED --add-exports java.desktop/sun.java2d=ALL-UNNAMED -Dfile.encoding=UTF-8 -p "D:\Eos2_1.1.x\EosRobotLib\bin;D:\Eos2_1.1.x\Distribution\jogamp-fat.jar;D:\Eos2_1.1.x\EosBaseLib\bin" -m de.lathanda.eos.robot/de.lathanda.eos.robot.Start
Reply | Threaded
Open this post in threaded view
|

Re: Crash in WindowsAWTWGLGraphicsConfigurationFactory

gouessej
Administrator
You use the option "-m", please read anew my tutorial, there's a section about modular projects. ALL-UNNAMED doesn't fit into your needs because this has to be used in non modular projects, which isn't your case.

Edit.: Look at the end of this subsection:
https://gouessej.wordpress.com/2020/04/05/javafx-et-jogl-fonctionnent-ensemble-javafx-and-jogl-work-together/#commandlineinterface
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Crash in WindowsAWTWGLGraphicsConfigurationFactory

Lathanda
many thanks, that's it

C:\Program Files\Java\jdk-14\bin\javaw.exe --add-exports java.base/java.lang=jogamp.fat --add-exports java.desktop/sun.awt=jogamp.fat --add-exports java.desktop/sun.java2d=jogamp.fat -Dfile.encoding=UTF-8 -p "D:\Eos2_1.1.x\EosRobotLib\bin;D:\Eos2_1.1.x\EosBaseLib\bin;D:\Eos2_1.1.x\Distribution\jogamp-fat.jar" -m de.lathanda.eos.robot/de.lathanda.eos.robot.Start
Reply | Threaded
Open this post in threaded view
|

Re: Crash in WindowsAWTWGLGraphicsConfigurationFactory

gouessej
Administrator
You're welcome, I'll mention "-m" in my tutorial to make it more obvious.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Crash in WindowsAWTWGLGraphicsConfigurationFactory

Sven Gothel
Administrator
On 6/18/20 5:02 PM, gouessej [via jogamp] wrote:
> You're welcome, I'll mention "-m" in my tutorial to make it more obvious.

Excellent!

Thank you both.

Earmarking this for a wiki entry in JogAmp.

Cheers, Sven
Reply | Threaded
Open this post in threaded view
|

Re: Crash in WindowsAWTWGLGraphicsConfigurationFactory

Alois
This post was updated on .
In reply to this post by Sven Gothel
Hello !
I got the same Exception with an swt.jar which I downloaded today
on https://jogamp.org/deployment/jogamp-current/archive/
As I don't have enough knowledge, can you explain me please how I can generate a new swt.jar without this bug ?
I work with Windows 10 64bit.

The problem seems to be in the jogl-all.jar.

Unfortunately I don't know how to do that.

Many thanks in advance.

Alois


Reply | Threaded
Open this post in threaded view
|

Re: Crash in WindowsAWTWGLGraphicsConfigurationFactory

gouessej
Administrator
Do you use the latest release candidate?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Crash in WindowsAWTWGLGraphicsConfigurationFactory

Martin
In reply to this post by Alois
Maybe this workaround can fix your issue : https://github.com/jzy3d/jogl/issues/12