Adnroid project fails with A/libc Fatal signal 11 (SIGSEGV), code 2, fault addr 0x40a00000 in tid 21434 (GCDaemon)

Hi all,
This is my first post in this forum, therefore I would like to admire the wonderful work you have done with this engine. I hope to be able to contribute to the community in the future. As a newbie I will start with a question. I have some trouble with a game I have been working on.

I have imported the jme3 libraries in a Gradle project and use them without significant troubles, till I tried to use com.jme3.collision.Collidable. collideWith(Collidable other, CollisionResults results). I will not go in details about the implementation because I created a small demo project that reproduces the issue. You can check it here.
https://bitbucket.org/aleksandar_angelov/jme_simple_demo/

However, I would like to share what I have found about the issue, because it can be useful (or complete crap :D).

The android logs dump this error:
01-01 13:00:12.731 21416-21434/? A/libc Fatal signal 11 (SIGSEGV), code 2, fault addr 0x40a00000 in tid 21434 (GCDaemon)

This says that the native libc tries to access invalid address. According to my poor experience with C this happens when we misuse some variable as address or we go out of some memory bound. addr 0x40a00000 is always mentioned in the error regardless the setup(the original game or the demo project I provide here). Therefore, I think that we are going out of some bound in the memory.
I have experimented with different size of the cube[] but I hit the same issue. I tried with size between 50 and 500. I had the impression that it takes longer to hit this error when we have fewer objects, which smells as memory leak.

Adding this to the android manifest file seems to solve the issue, but as far as I understand this is temporary solution, which is only for development purposes.
android:vmSafeMode=“true”
android:allowClearUserData=“true”
android:hardwareAccelerated=“true”

Can you share your opinion on this subject .
A workaround will be very helpful.

Alek

1 Like

Its 3.0 or 3.1 ?
Did you check the android versions of your mobile x skd ?
Did you check if this works with other mobiles ?

I am still using jme 3.0
I have tried to compile the project with different sdk just to see if something change, but the problem persists.
Also I have tried it on different devices (Samsung Note 3 runnitng Android 5.0 and Samsung Galaxy Tab S running Android 5.0.2) and the issue happens on both of them.

I did notice you describe that you are using physics.
I know jbullet dosent work on android, the jm3 do some internal conversion to bullet when it compiles.
I think your problem is there, since you are using grade its not making this conversion.
Can you try to remove/comment the physics part and test it ?

No I am not using bullet at all. It is not included in the build.gradle file and I have checked that it is not used by some transitive dependency.

PS.
In fact this is the point of my use case. I just want to detect collisions without using the bullet library. I do not need all the things bullet calculates. I just want to know if 2 object collide and I do not care about forces …
If there is other method to find a collision very cheaply it will resolve my issue.
Nevertheless, the problem with android and collideWith should be investigated because it is possible to be a bug in the library.

Could you try the default ray tests if they crash with the same error? Maybee you project does something strange.

Which if those is actually required? Probably not all three.

collideWith() doesn’t do anything special really except when it gets down to triangle intersection. Then it will iterate over the native buffers. So if your meshes are messed up then perhaps memory is being accessed that doesn’t exist or something.

Anyway, collideWith() between two spatials may not be doing what you want since mesh to mesh collisions are not supported. At best you get bounding shape to mesh… which now that I’ve clicked through the 500 links to see your code I see you are already using bounding shapes on one end. But for spatial to spatial collisions as you say in your first post it might be better to use bounding shape to bounding shape anyway and not use collideWith at all. Since triangle accurate collisions between two spatials is not possible.

I will go ahead and include the code to save everyone else the trouble. I almost didn’t even bother with the post but you caught me in a very rare case of having a few minutes to kill.

public class MySimpleApplication extends SimpleApplication{
    public Spatial[] cubes;
    public Node environmentNode;
    public BoundingSphere collisionShape;

    @Override
    public void simpleInitApp() {

        collisionShape = new BoundingSphere(5f, new Vector3f());

        environmentNode = new Node("environmentNode");
        cubes = new Spatial[500];
        for (int i = 0; i < cubes.length; i++) {
            cubes[i] = new Geometry("Box "+i, new Box(1,1,1));
            Material mat1 = new Material(assetManager,
                    "Common/MatDefs/Misc/Unshaded.j3md");
            mat1.setColor("Color", ColorRGBA.randomColor());
            cubes[i].setMaterial(mat1);
            cubes[i].move(i*10, i*10, i*10);
            environmentNode.attachChild(cubes[i]);
        }
        rootNode.attachChild(environmentNode);
    }

    @Override
    public void simpleUpdate(float tpf) {
        CollisionResults environmentCollisionResults = new CollisionResults();
        environmentNode.collideWith(collisionShape, environmentCollisionResults);
        if (environmentCollisionResults.size() > 0) {
            System.out.println("Collision!!!!!");
        }
    }

}

I have tried to detect collision between ray and simple boxes and it works ok. The problems occurs when I use BoundingSphere and BoundingBox. In my real project I do many strange stuff, therefore I reproduced the problem in a small very simple project which I share in the first post. I have done this for debugging first in order to exclude all side factors. The second reason is to give something very simple here.

You mean I can not use JME physics for android ?

You are right about the options the only one needed is android:vmSafeMode=“true” , which is used for debugging and make the game way slower which makes this options useless as workaround.

I totally agree with this. In fact, this was one of the first thing to check . As a result, in this simple demo project I use only objects which come out of the box with the jme libraries. Therefore, I have excluded this as a reason for the problem.

I will take your advice and try to do bounding shape to bounding shape collision detection.

Nevertheless, I think it worth investigating the problem because as you see I use very basic code which is absolutely fine according to docs I have read. In this demo I do not use any custom models or methods. I really do not think that the problem is in 10 line code here, but in the way jme communicating with the native android libraries.

Given that other people don’t seem to be running into this, it could be specific to your device. I don’t know how many devices you’ve tried it on but maybe publish the prepackaged app here for others to test.

You can totally use physics on android. The said here is that on android you have to use the native bullet libraries. The are C implemented and probably more appropriate to be used on a phone/tablet.
On desktop, you can use jbullet library which is Java implemented and this library is not implemented for android as far as I know(at least for jme 3.0).
Hence, If you are implementing a game targeting android just use the native bullet libraries.

1 Like

I have two package for bullet.
1- com.jme3.bullet.*
2-com.bulletphysics.*
So you mean I should use 1st one?

On Android, JME always uses native bullet. On desktop, you just have to use different libraries.

Packages never come into it.

1 Like

Here is apk from the project given in the git repo in the firts post:
https://drive.google.com/folderview?id=0B93OTFHXW8aqMmlicEYwODlRd3M&usp=sharing

Some times it takes quite long to hit the error, so if it runs longer than a minute just launch it again.
No track is thrown just the app quit with “Unfortunally, My Application has stopped”

Someone tried this ?
I have tried on as many device as I could and here is the results:
Android 4.2 (tried on one device) runs like a charm. No problems at all.
Android 5.0 (tried on several devices) crash on every single on of them.
Android 6.0 (tried on one device) runs like a charm. No problems at all.

I have consulted with a guy at work whose previous job was android game developing. His exact words was: “There is a bug and its a fat one. It is possible to be in the android native libs, but I doubt it. File a bug to the jme developers it most likely there.” We had only 15 minutes to discuss and debug but knowing the quality of the people at work I really stand by his words.

If you think there is any bug, build an very small and easy to run test case, preferentially one that fills in only one class, and past the code ( formated please ) here, so we can look for you.
Anyway, for my experience with android, right now for example, I am looking for an issue that happens with my wife mobile, but works on my mobile, and both devices are almost the same model… Android development is trick, needs a lot of testing in different devices, also, notice that you can compile the app in different android versions, it may reated to your problem…