Hello Guest

[FIXED] Urgent panic - JRE7 / LWJGL / Linux broken

  • 23 Replies
  • 64516 Views
*

Offline princec

  • *****
  • 1933
    • Puppygames
[FIXED] Urgent panic - JRE7 / LWJGL / Linux broken
« on: July 29, 2011, 15:23:07 »
Full summary here: basically the update to Java 7 is breaking everyones' LWJGL games. Looks like libjawt.so has once again managed to creep into AWT dependency somehow - I seem to recall issues similar to this years ago on Windows. Anybody working on the Linux port here confirm that it's a simple fix (or knows one?)

Cas :)

*

Offline kappa

  • *****
  • 1319
Re: [BUG] Urgent panic - JRE7 / LWJGL / Linux broken
« Reply #1 on: July 29, 2011, 15:50:04 »
Following the above post links to another here http://getsatisfaction.com/mojang/topics/minecraft_doesnt_work_with_java_7

Which states the error with Java 7 is the following:

Code: [Select]
home/andrey/.minecraft/bin/natives/liblwjgl.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)
There is a workaround mentioned in the comments on that post.

There was recently a fix applied to LWJGL which changed the way it loads 32/64bit natives so the nightly builds might already work, can anyone confirm if nightly builds also fail?
« Last Edit: July 29, 2011, 15:54:44 by kappa »

*

Offline kulpa

  • *
  • 11
Re: [BUG] Urgent panic - JRE7 / LWJGL / Linux broken
« Reply #2 on: July 29, 2011, 17:28:09 »
nope, not working.
downloaded fresh archive from Jenkins (jars #1276, liblwjgl.so #1326, liblwjgl64.so #1330)
Code: [Select]
$ unset LD_LIBRARY_PATH
$ java -cp libs/lwjgl.jar:libs/lwjgl_test.jar -Djava.library.path=libs/linux/ -Dorg.lwjgl.util.Debug=true org.lwjgl.test.DisplayTest
==== Test Current ====
Info about current:
[LWJGL] Failed to load 64 bit library: /home/kulpae/sandbox/LWJGL/libs/linux/liblwjgl64.so: libjawt.so: cannot open shared object file: No such file or directory
[LWJGL] Failed to load 64 bit library: /home/kulpae/sandbox/LWJGL/libs/linux/liblwjgl64.so: libjawt.so: cannot open shared object file: No such file or directory
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
at java.lang.Runtime.loadLibrary0(Runtime.java:845)
at java.lang.System.loadLibrary(System.java:1084)
at org.lwjgl.Sys$1.run(Sys.java:73)

now after the fix:
Code: [Select]
$ export LD_LIBRARY_PATH="/opt/java/jre/lib/amd64"
$ java -cp libs/lwjgl.jar:libs/lwjgl_test.jar -Djava.library.path=libs/linux/ org.lwjgl.test.DisplayTest
==== Test Current ====
Info about current:
Graphics card: null, version: null
Resolution: 1600x900x24@60Hz
---- Test Current ----
==== Test query ====
Retrieving available displaymodes
Found 6 modes
...

Code: [Select]
$ uname -srm
Linux 3.0-ARCH x86_64
java -version
$ java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)

edit: compiled from svn, still the same issue...
edit2: this also works..
Code: [Select]
$ unset LD_LIBRARY_PATH
$ sudo ldconfig /opt/java/jre/lib/amd64/
« Last Edit: July 29, 2011, 21:58:09 by kulpa »

*

Offline Matzon

  • *****
  • 2242
Re: [BUG] Urgent panic - JRE7 / LWJGL / Linux broken
« Reply #3 on: July 29, 2011, 23:36:48 »
so, who is the problem exactly ?

Re: [BUG] Urgent panic - JRE7 / LWJGL / Linux broken
« Reply #4 on: July 29, 2011, 23:56:08 »
There was recently a fix applied to LWJGL which changed the way it loads 32/64bit natives so the nightly builds might already work, can anyone confirm if nightly builds also fail?
As described in the linked thread, there are other issues after working around the ELFCLASS errors, but
Code: [Select]
sudo ldconfig /opt/java/jre/lib/amd64
seems to resolve this. There seems to be some confusion over whether this is a packaging problem specific to distros, which would seem to be the case if we simply need to use ldconfig, or if there is a real problem with lwjgl. Diagnosis based on this info?

*

Offline kappa

  • *****
  • 1319
Re: [BUG] Urgent panic - JRE7 / LWJGL / Linux broken
« Reply #5 on: July 31, 2011, 00:39:24 »
doing some searching on this problem it seems that there was a similar issue with libjawt.so all the way back in the LWJGL 0.95 days. The fix that was eventually used was calling the following code before the lwjgl natives are loaded:

Code: [Select]
static {
java.awt.Toolkit.getDefaultToolkit(); // This will make sure libjawt.so is loaded
}


It could be that Java 7 is somehow changing this behaviour making it a JRE bug.
« Last Edit: July 31, 2011, 00:43:00 by kappa »

*

Offline kappa

  • *****
  • 1319
Re: [BUG] Urgent panic - JRE7 / LWJGL / Linux broken
« Reply #6 on: August 04, 2011, 11:21:24 »
I posted this problem on one of the java mailing lists and got the following response:

Quote
> Hi,

If adding the library on the system library path is fixing it, it could be related to:

6367077: Purge LD_LIBRARY_PATH usage from the launcher
http://hg.openjdk.java.net/jdk7/jdk7/jdk/rev/de45eac5670e

'Previously the launcher modified the LD_LIBRARY_PATH appropriately for the
 desired data model path, regardless if data models matched or not. The
 launcher subsequently exec'ed the desired executable, in order to make the
 LD_LIBRARY_PATH path available for the runtime linker. This is no longer the
 case, the launcher dlopens the target libjvm.so. All other required
 libraries are loaded by the runtime linker, by virtue of the $ORIGIN paths
 baked into the shared libraries, by the build infrastructure at compile time.'

Have you only seen this with LWJGL i.e. can other Java applications find libjawt.so?

--
Andrew :)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

Support Free Java!
Contribute to GNU Classpath and IcedTea
http://www.gnu.org/software/classpath
http://icedtea.classpath.org

So not sure if this will still be considered a JRE bug.

Discussing this further on the LWJGL IRC Channel it was suggested that libjawt.so gets loaded with Toolkit.getDefaultToolkit() (by dlopening), but the linker doesn't see it as it's not in LD_LIBRARY_PATH and this problem might be worked around by using "dlsym(NULL, "JAWT_GetAWT")".
« Last Edit: August 04, 2011, 11:23:15 by kappa »

*

Offline kappa

  • *****
  • 1319
Re: [BUG] Urgent panic - JRE7 / LWJGL / Linux broken
« Reply #7 on: August 05, 2011, 18:37:47 »
ok here's a temp fix for those that need one urgently. At the start of your program (before any LWJGL calls) run the following snippet of code.

Code: [Select]
String osArch = System.getProperty("os.arch");
boolean is64bit = "amd64".equals(osArch) || "x86_64".equals(osArch);

java.awt.Toolkit.getDefaultToolkit(); // loads libmawt.so (needed by jawt)

if (is64bit) System.load(System.getProperty("java.home") + "/lib/amd64/libjawt.so");
else System.load(System.getProperty("java.home") + "/lib/i386/libjawt.so");

This should get your stuff working on Java 7 Linux for now, while a proper fix that can be integrated into LWJGL is investigated.

LWJGL has been relying on java.awt.Toolkit.getDefaultToolkit() to load jawt on linux but its no longer the behaviour of the method with Java 7.
« Last Edit: August 05, 2011, 20:17:08 by kappa »

*

Offline kappa

  • *****
  • 1319
Re: [BUG] Urgent panic - JRE7 / LWJGL / Linux broken
« Reply #8 on: August 06, 2011, 13:41:53 »
This issue should now be fixed and will be part of the next nightly build. Do test and provide feedback on whether it works.

*

Offline kulpa

  • *
  • 11
Re: [FIXED] Urgent panic - JRE7 / LWJGL / Linux broken
« Reply #9 on: August 06, 2011, 15:39:41 »
confirmed, is working now

Re: [FIXED] Urgent panic - JRE7 / LWJGL / Linux broken
« Reply #10 on: October 07, 2011, 17:34:56 »

*

Offline kappa

  • *****
  • 1319
Re: [FIXED] Urgent panic - JRE7 / LWJGL / Linux broken
« Reply #11 on: October 07, 2011, 17:47:30 »
You must still be using the old lwjgl.jar. That is the is the most important file to replace for the fix, do double check that it is indeed using the nightly version of this jar.
« Last Edit: October 07, 2011, 18:54:59 by kappa »

Re: [FIXED] Urgent panic - JRE7 / LWJGL / Linux broken
« Reply #12 on: October 07, 2011, 18:23:48 »
Ok, your sentence is not so easy to translate into german, but what I understand is: I have to check, if Tectonicus is using the nightly version of lwjgl.jar, right?

Re: [FIXED] Urgent panic - JRE7 / LWJGL / Linux broken
« Reply #13 on: October 07, 2011, 20:29:45 »
I backupped the files in /usr/shared/java and copied the new version of the files in. Also the new files are in the Tectonicus- and Minecraft-folders, but ist's still the same error. What's wrong?

Re: [FIXED] Urgent panic - JRE7 / LWJGL / Linux broken
« Reply #14 on: October 08, 2011, 12:14:17 »
To show which files I updated, I executed a find-command:

Code: [Select]
server@kastenbier:~$ sudo find / -name "*lwjgl*"
/home/server/.tectonicus/native/lwjgl.dll
/home/server/.tectonicus/native/liblwjgl.so
/home/server/.tectonicus/native/lwjgl64.dll
/home/server/.tectonicus/native/liblwjgl64.so
/home/server/.tectonicus/native/liblwjgl.jnilib
/home/server/.minecraft/bin/lwjgl.jar.bak
/home/server/.minecraft/bin/natives/liblwjgl.so
/home/server/.minecraft/bin/natives/liblwjgl64.so
/home/server/.minecraft/bin/lwjgl.jar
/home/server/.minecraft/bin/lwjgl_util.jar
/home/server/lwjgl
/home/server/lwjgl/liblwjgl.so
/home/server/lwjgl/lwjgl.jar
/home/server/lwjgl/lwjgl_util.jar
/home/server/lwjgl/lwjgl_test.jar
/home/server/lwjgl/liblwjgl64.so
/home/server/lwjgl/lwjgl_util_applet.jar
/home/server/lwjgl/lwjgl-debug.jar
/var/lib/dpkg/info/liblwjgl-java-jni.md5sums
/var/lib/dpkg/info/liblwjgl-java-jni.list
/var/lib/dpkg/info/liblwjgl-java.md5sums
/var/lib/dpkg/info/liblwjgl-java.list
/var/cache/apt/archives/liblwjgl-java-jni_2.7.1+dfsg-1_amd64.deb
/var/cache/apt/archives/liblwjgl-java_2.7.1+dfsg-1_all.deb
/usr/share/doc/liblwjgl-java-jni
/usr/share/doc/liblwjgl-java
/usr/share/java/lwjgl_util.jar
/usr/share/java/lwjgl_util.jar.bak
/usr/share/java/lwjgl.jar
/usr/share/java/lwjgl.jar.bak
/usr/share/java/lwjgl_test.jar
/usr/share/java/lwjgl_test.jar.bak
/usr/share/java/lwjgl_util_applet.jar
/usr/share/java/lwjgl_util_applet.jar.bak
/usr/lib/jni/liblwjgl.so.bak
/usr/lib/jni/liblwjgl.so

Also .tetonicus and .minecraft got the new files, but without backupping the old ones.