[SOLVED] Native Bullet x86 crash

Hello!

jme3test.helloworld.HelloPhysics gives immediate crash:

A fatal error has been detected by the Java Runtime Environment:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x169acbac, pid=3624, tid=0x000010f8

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.jme3.bullet.PhysicsSpace.addRigidBody(JJ)V+0
j com.jme3.bullet.PhysicsSpace.addRigidBody(Lcom/jme3/bullet/objects/PhysicsRigidBody;)V+75
j com.jme3.bullet.PhysicsSpace.addCollisionObject(Lcom/jme3/bullet/collision/PhysicsCollisionObject;)V+30
j com.jme3.bullet.control.RigidBodyControl.setPhysicsSpace(Lcom/jme3/bullet/PhysicsSpace;)V+38
j com.jme3.bullet.PhysicsSpace.add(Ljava/lang/Object;)V+12
j jme3test.helloworld.HelloPhysics.makeBrick(Lcom/jme3/math/Vector3f;)V+66
j jme3test.helloworld.HelloPhysics.initWall()V+50
j jme3test.helloworld.HelloPhysics.simpleInitApp()V+71
j com.jme3.app.SimpleApplication.initialize()V+282
j com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread()Z+90
j com.jme3.system.lwjgl.LwjglAbstractDisplay.run()V+36
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub

JME was built from current master (which is JME v3.2). JRE version: 8.0_92-b14. Native bullet is used. Access violation bug happens only on x86 JRE (and of course x86 bulletjme.dll). Same JME build works fine on x64 JRE and x64 bulletjme.dll. Operation system is windows 7 x64. Maybe native bullet x86 should not work on x64 windows? I doubt this.

If to rebuild JME from May, 4th 2015 (it is previous version of native\windows\x86\bulletjme.dll), then native bullet works fine on JRE x86. Last time bulletjme.dll was changed on 22nd, April, 2016, and this version gives access violation. Looks like something broke the native bullet between those dates. There are many commits to cpp files without rebuilt dlls. If I manage to understand how to build those dll myslef, I could find the commit, which introduced the bug. It is also possible, that issue is because I use Java 8 instead of Java 7.

jBullet doesn’t work either for the current master :frowning: It gives such exception:

java.lang.NoClassDefFoundError: com/bulletphysics/collision/dispatch/CollisionConfiguration
	at com.jme3.bullet.BulletAppState.startPhysics(BulletAppState.java:164)
	at com.jme3.bullet.BulletAppState.stateAttached(BulletAppState.java:211)
	at com.jme3.app.state.AppStateManager.attach(AppStateManager.java:133)
	at jme3test.helloworld.HelloPhysics.simpleInitApp(HelloPhysics.java:101)
	at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:220)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:211)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.bulletphysics.collision.dispatch.CollisionConfiguration
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 8 more

So, currently I can’t launch physics with any bullet physics implementation on Windows JRE x86. I am more interested in the native bullet though, and any advice how to fix the issue is welcome.

Thank you!

There was an issue with the build script, it got fixed but afaik it has never been recompiled since then.
If you recompile it manually (remember to set buildNativesProjects=true in gradle.properties ) it should work.

You can’t use x86 libs in jre x86_64, but this is not a problem since the build script compiles for both 32 bit and 64 bit if you launch it from a 64 bit os.

1 Like

@RiccardoBlb, thank you for the help! I have enabled buildNativeProjects = true, installed i686-w64-mingw32-gcc-4.7.2-release-win32_rubenvb and LLVM-3.8.0-win32. Native bullet x86 dll was successfully recompiled. But this time I get the exception:

java.lang.UnsatisfiedLinkError: com.jme3.bullet.PhysicsSpace.createPhysicsSpace(FFFFFFIZ)J
	at com.jme3.bullet.PhysicsSpace.createPhysicsSpace(Native Method)
	at com.jme3.bullet.PhysicsSpace.create(PhysicsSpace.java:157)
	at com.jme3.bullet.PhysicsSpace.<init>(PhysicsSpace.java:150)
	at com.jme3.bullet.BulletAppState.startPhysics(BulletAppState.java:164)
	at com.jme3.bullet.BulletAppState.stateAttached(BulletAppState.java:211)
	at com.jme3.app.state.AppStateManager.attach(AppStateManager.java:133)
	at jme3test.helloworld.HelloPhysics.simpleInitApp(HelloPhysics.java:101)
	at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:220)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:211)
	at java.lang.Thread.run(Thread.java:745)

Maybe native bullet doesn’t like mingw or such version is not supported. Or anything else. I can’t find the instruction for building the native bullet. Need to investigate…

Be sure to remove the library extracted in your project root.
Are you trying this on linux or windows?

Jbullet doesn’t work because you miss the Jbullet.jar and the stack-alloc.jar etc.
See the engines or sdks lib folder

1 Like

Library in the root is the same as in the build. I compared by content. I try on Windows.

Yes, you are right. If to get these mentioned jars, then app works fine on jBullet with JRE x86. Strange that script has

    compile files('../lib/jbullet.jar', '../lib/stack-alloc.jar')

libraries are present, but they don’t go to to build.

Maybe that means they are compile-time-dependencies whereas they are solely runtime-dependencies which simply need to be packaged along with the “Game.jar”

Ok. I have found the issue with the build. I checked exported functions and they all have appended @ in the end. For example, Java_com_jme3_bullet_PhysicsSpace_createPhysicsSpace@40. Same function in already present dll is Java_com_jme3_bullet_PhysicsSpace_createPhysicsSpace. Mingw has option --kill-at, which removes this @ from all exported functions. I have added it, so now next build row looks like this:

linker.args "-Wl,--exclude-all-symbols,--kill-at"

Produced x86 dll works fine. Finally I managed to run native bullet on 32 bits JRE! :smiley:

Thank everyone for help!

2 Likes

Has anyone got a recompiled version to share?. Currently I don’t have a proper environment to recompile it myself and I’m having the same issue with 3.1.0-stable from jcenter.

Try this:

repositories {
   maven {
     url "http://dl.bintray.com/riccardo/jme3-bullet-native"
   }
}
dependencies {
    compile "org.jmonkeyengine.bullet_builder:jme3-bullet-native:jmonkeyengine-master-3.2c"
}
1 Like

Thanks, it works fine.