[SOLVED] Fatal error in JRE when using Minie

Again, the physics engine gives me an error…
It is:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fb0d2801150, pid=12369, tid=12457
#
# JRE version: OpenJDK Runtime Environment (11.0.11+9) (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
# Java VM: OpenJDK 64-Bit Server VM (11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C  [libbulletjme.so+0x105150]  btDbvtBroadphase::setAabb(btBroadphaseProxy*, btVector3 const&, btVector3 const&, btDispatcher*)+0x20
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P %E" (or dumping to game/core.12369)
#
# An error report file with more information is saved as:
# game/hs_err_pid12369.log
#
# If you would like to submit a bug report, please visit:
#   https://bugs.launchpad.net/ubuntu/+source/openjdk-lts
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

This happens randomly. Also, I haven’t changed the code that I’ve used for jme3-jbullet before.

1 Like

If you can reproduce the crash using “Minie-4.5.0+debug” with assertions enabled, that might tell us more.

If you can’t, post the “hs_err_pid12369.log” file, and I’ll take a look at it.

The return of debug version in the console is the same, so here is the log file with debug on:
https://drive.google.com/file/d/1GncIWoWD3ukgsp5TT6JLETpW1aEsIC4k/view?usp=sharing
As I see the problem is in the Aabb function(as it was before jme3-jbullet, also).

1 Like

This is a crash I’ve not seen before.

I see you’re using a BulletAppState in parallel-threaded mode. I wonder if perhaps the PhysicsSpace is being modified by multiple threads. Does the same problem occur if you set the BulletAppState to the default (single-threaded) mode?

Yes, it is

Ambiguous referent “it”. The PhysicsSpace is being modified by multiple threads?

I have set ThreadingType to BulletAppState.ThreadingType.SEQUENTIAL, but the error appears again

1 Like

Very interesting!

I’d like to debug this locally. Can you supply me with a simple app that consistently reproduces the problem?

I’ll work for it

1 Like

Here you are:
https://drive.google.com/file/d/1pzk9hnoZZsZocG9YKye6m8xTUKNfOyJm/view?usp=sharing
A very simplified version of my game. Crashing in momentum.

1 Like

I have tried to execute

spat.addControl(phys);
state.add(phys);

in app thread, and I receive this:

java: /home/travis/build/stephengold/Libbulletjme/src/main/native/bullet3/LinearMath/btVector3.h:305: btVector3& btVector3::normalize(): Assertion `!fuzzyZero()' failed.
Aborted (core dumped)
1 Like

The PhysicsSpace is being modified by multiple threads here:

    void createBoxGrid() {
        new Thread(() -> {
            for (int x = 0; x < 16; x++) {
                for (int y = 0; y < 16; y++) {
                    createBox(x, y);
                }
            }
        }).start();
    }

where createBox() does

        PhysicsSpace state = bulletAppState.getPhysicsSpace();
...
        state.add(phys);

That’s an issue, since PhysicsSpace.add() is not thread-safe.

However, after I serialized createBoxGrid() and spawnObject(), there was still a problem:

java: /home/travis/build/stephengold/Libbulletjme/src/main/native/bullet3/LinearMath/btVector3.h:305: btVector3& btVector3::normalize(): Assertion `!fuzzyZero()’ failed.

I’m still investigating that crash.

I believe the fuzzyZero crash relates to creating mesh collision shapes with zero thickness in createBox() when x=0 or y=0. I assume you didn’t intend to do that.

Of course, a zero-thickness shape shouldn’t crash the JRE. That’s a bug in my code. I’ll open an issue against Minie and develop a fix.

If for some reason you need to create zero-thickness shapes, you can work around the bug by using Minie v4.4.0 instead of v4.5.0.

EDIT:

1 Like

Yes, I have created this test game to reproduce that bug in a hurry, so I haven’t expected that. In my main game that chunks are moving in a grid, so there is no that fuzzyZero bug. Downgrading helps, there is no that native bug, thanks!

1 Like

Uh-oh, there is another exception:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fef65cf2136, pid=27475, tid=27476
#
# JRE version: OpenJDK Runtime Environment (11.0.11+9) (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
# Java VM: OpenJDK 64-Bit Server VM (11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C  [libbulletjme.so+0x12a136]  removeleaf(btDbvt*, btDbvtNode*)+0x16
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P %E" (or dumping to game/core.27475)
#
# An error report file with more information is saved as:
# game/hs_err_pid27475.log
#
# If you would like to submit a bug report, please visit:
#   https://bugs.launchpad.net/ubuntu/+source/openjdk-lts
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Log file:
https://drive.google.com/file/d/1CrRLJ3r-bPqJx9l_hwoc8GGp1LqSeaMX/view?usp=sharing

The Google Drive link you sent me is for “hs_err_pid14980.log” but the crash message you quoted is for “hs_err_pid27475.log”.

Are you sure the PhysicsSpace isn’t being modified by multiple threads?

Yes, also after I posted that I have run it in app thread, so I have already fixed it

1 Like

Also, I have error when exporting app to .jar:
java.lang.UnsatisfiedLinkError: 'void

com.jme3.bullet.collision.shapes.CollisionShape.setContactFilterEnabled(long, boolean)'
	at com.jme3.bullet.collision.shapes.CollisionShape.setContactFilterEnabled(Native Method)
	at com.jme3.bullet.collision.shapes.CollisionShape.setContactFilterEnabled(CollisionShape.java:326)
	at com.jme3.bullet.collision.shapes.CapsuleCollisionShape.createShape(CapsuleCollisionShape.java:213)
	at com.jme3.bullet.collision.shapes.CapsuleCollisionShape.<init>(CapsuleCollisionShape.java:90)
	at com.jme3.bullet.control.BetterCharacterControl.getShape(BetterCharacterControl.java:843)
	at com.jme3.bullet.control.BetterCharacterControl.<init>(BetterCharacterControl.java:185)
        ...

It’s about native libraries. When I run it in vscode, all is fine.

Please show me the rest of the stack trace.

java.lang.UnsatisfiedLinkError: 'void com.jme3.bullet.collision.shapes.CollisionShape.setContactFilterEnabled(long, boolean)'
	at com.jme3.bullet.collision.shapes.CollisionShape.setContactFilterEnabled(Native Method)
	at com.jme3.bullet.collision.shapes.CollisionShape.setContactFilterEnabled(CollisionShape.java:326)
	at com.jme3.bullet.collision.shapes.CapsuleCollisionShape.createShape(CapsuleCollisionShape.java:213)
	at com.jme3.bullet.collision.shapes.CapsuleCollisionShape.<init>(CapsuleCollisionShape.java:90)
	at com.jme3.bullet.control.BetterCharacterControl.getShape(BetterCharacterControl.java:843)
	at com.jme3.bullet.control.BetterCharacterControl.<init>(BetterCharacterControl.java:185)
	at com.mais3d.game.App.initPlayer(App.java:164)
	at com.mais3d.game.App.initGame(App.java:96)
	at com.mais3d.util.graphics.UI.screens.MainScreen$1$1$1.call(MainScreen.java:40)
	at com.mais3d.util.graphics.UI.screens.MainScreen$1$1$1.call(MainScreen.java:1)
	at com.jme3.app.AppTask.invoke(AppTask.java:142)
	at com.jme3.app.LegacyApplication.runQueuedTasks(LegacyApplication.java:701)
	at com.jme3.app.LegacyApplication.update(LegacyApplication.java:715)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:246)
	at com.jme3.system.lwjgl.LwjglWindow.runLoop(LwjglWindow.java:530)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:632)
	at com.jme3.system.lwjgl.LwjglWindow.create(LwjglWindow.java:466)
	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:127)
	at com.mais3d.game.App.setUp(App.java:197)
	at com.mais3d.game.App.main(App.java:62)
1 Like