code-disaster / steamworks4j

A thin Java wrapper to access the Steamworks API
https://code-disaster.github.io/steamworks4j/
MIT License
467 stars 64 forks source link

64Bit Linux loads wrong lib file #56

Closed AlrikG closed 6 years ago

AlrikG commented 7 years ago

I've received an error report from one of my testers. He uses Linux mint 64bit but libsteam_api.so was loaded instead of libsteam_api64.so.

This is the error report:

**********  qb-CrashReport (7/1/17 12:56 AM) **********

java.lang.UnsatisfiedLinkError: /tmp/steamworks4j/1.7.0-SNAPSHOT/libsteam_api.so: /tmp/steamworks4j/1.7.0-SNAPSHOT/libsteam_api.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)

**** Details ****

**** Environment ****

Java: 1.8.0_121 64 Bit Oracle Corporation
JVM Args: -Xmx2G
Memory (DIRECT): 1 MB (used) / 89 Buffers
Memory (HEAP): 45 MB (used) / 195 MB (free) / 240 MB (total) / 1820 MB (max)
OpenGL Renderer Information: 
 * Vendor: NVIDIA Corporation
 * Renderer: GeForce GTX 1050 Ti/PCIe/SSE2
 * OpenGL Version: 3.2.0 NVIDIA 375.39
 * GLSL Version: 1.50 NVIDIA via Cg compiler
OS: Linux 4.4.0-77-generic amd64
Processors: 4
qb-Version: 0.3.0.2

**** StackTrace ****

java.lang.UnsatisfiedLinkError: /tmp/steamworks4j/1.7.0-SNAPSHOT/libsteam_api.so: /tmp/steamworks4j/1.7.0-SNAPSHOT/libsteam_api.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1086)
    at com.codedisaster.steamworks.SteamSharedLibraryLoader.loadLibrary(SteamSharedLibraryLoader.java:122)
    at com.codedisaster.steamworks.SteamAPI.init(SteamAPI.java:19)
    at com.codedisaster.steamworks.SteamAPI.init(SteamAPI.java:10)
    at Bw.<init>(Unknown Source)
    at net.qb.QbClient.simpleInitApp(Unknown Source)
    at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:220)
    at com.jme3.system.lwjgl.QbWindow.initInThread(Unknown Source)
    at com.jme3.system.lwjgl.QbWindow.run(Unknown Source)
    at com.jme3.system.lwjgl.QbWindow.create(Unknown Source)
    at com.jme3.app.LegacyApplication.start(LegacyApplication.java:463)
    at com.jme3.app.LegacyApplication.start(LegacyApplication.java:424)
    at com.jme3.app.SimpleApplication.start(SimpleApplication.java:125)
    at net.qb.QbClient.<init>(Unknown Source)
    at net.qb.QbClient.main(Unknown Source)
code-disaster commented 7 years ago

I removed support for Linux 32-bit in the latest version (for various reasons, but mostly because it causes more headache than being worth the hassle).

It now always loads libsteam_api.so, which is the 64-bit version.

Please let me know if there are still issues.

AlrikG commented 7 years ago

Hi I still have crashes for the server part but as far as I can see the linux 64bit problem is gone and the steam client is working. I don't have enough linux skills to get the problem :/

The crash logs (tested with Java and OpenJDK) from my linux tester:

linuxCrashLog.zip

summary:

Stack: [0x00007f73a471e000,0x00007f73a481f000],  sp=0x00007f73a481c0f8,  free space=1016k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [ld-linux-x86-64.so.2+0x1b903]
C  [ld-linux-x86-64.so.2+0x155e2]
C  [ld-linux-x86-64.so.2+0x10564]
C  [libdl.so.2+0xf09]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  java.lang.ClassLoader$NativeLibrary.load(Ljava/lang/String;Z)V+0
j  java.lang.ClassLoader.loadLibrary0(Ljava/lang/Class;Ljava/io/File;)Z+328
j  java.lang.ClassLoader.loadLibrary(Ljava/lang/Class;Ljava/lang/String;Z)V+48
j  java.lang.Runtime.load0(Ljava/lang/Class;Ljava/lang/String;)V+57
j  java.lang.System.load(Ljava/lang/String;)V+7
j  com.codedisaster.steamworks.SteamSharedLibraryLoader.loadLibrary(Ljava/lang/String;Ljava/lang/String;)V+89
j  com.codedisaster.steamworks.SteamGameServerAPI.init(Ljava/lang/String;ISSSLcom/codedisaster/steamworks/SteamGameServerAPI$ServerMode;Ljava/lang/String;)Z+40
j  com.codedisaster.steamworks.SteamGameServerAPI.init(ISSSLcom/codedisaster/steamworks/SteamGameServerAPI$ServerMode;Ljava/lang/String;)Z+9
j  BV.initialize(Lcom/jme3/app/state/AppStateManager;Lcom/jme3/app/Application;)V+93
j  com.jme3.app.state.AppStateManager.initializePending()V+80
j  com.jme3.app.state.AppStateManager.update(F)V+5
j  com.jme3.app.SimpleApplication.update()V+77
j  com.jme3.system.NullContext.run()V+8
j  java.lang.Thread.run()V+11
v  ~StubRoutines::call_stub
code-disaster commented 7 years ago

I've never seen it crash natively inside loadLibrary() before. No idea how to solve that. What Linux distribution is he testing on?

AlrikG commented 7 years ago

Hm ok. It's only the SteamGameServerAPI part that is not working for him. He has "Ubuntu Mate 1.16.2" installed

AlrikG commented 6 years ago

Are there any news? Does the SteamGameServerAPI works on linux?

code-disaster commented 6 years ago

It's hard to say w/o a real test case, but at least SteamGameServerAPITest launches w/o problems here on Ubuntu 16.04 64-bit. The test doesn't do much, but it passes SteamGameServerAPI.init().

AlrikG commented 6 years ago

I tested it on Ubuntu 17.10. 64Bit. The problem only occurs when starting the server after the client. Here is a test case. The dump file is included. SteamworksServerTest.zip

code-disaster commented 6 years ago

Good point. I was able to reproduce the crash now. Looks like Linux isn't happy about loading the same shared library twice.

AlrikG commented 6 years ago

Awesome thank you! Now my game has linux support :) Btw. you can add it to your showcase list if you wish http://store.steampowered.com/app/601400/qb/