Android Fatal Signal 11

2019-01-22 10:36发布

In the app I'm developing on Android, I keep getting a Fatal Signal 11 error.

I think it's something to do with the way that I'm accessing the memory but I can't figure out what is causing it.

Any help will be much appreciated!

Here's the LogCat:

05-02 23:47:17.618: D/dalvikvm(590): GC_FOR_ALLOC freed 68K, 4% free 6531K/6787K, paused 101ms
05-02 23:47:17.638: I/dalvikvm-heap(590): Grow heap (frag case) to 7.619MB for 1228816-byte allocation
05-02 23:47:17.738: D/dalvikvm(590): GC_CONCURRENT freed 1K, 4% free 7730K/8007K, paused 5ms+14ms
05-02 23:47:17.878: D/dalvikvm(590): GC_FOR_ALLOC freed <1K, 4% free 7730K/8007K, paused 37ms
05-02 23:47:17.888: I/dalvikvm-heap(590): Grow heap (frag case) to 8.790MB for 1228816-byte allocation
05-02 23:47:17.998: D/dalvikvm(590): GC_CONCURRENT freed <1K, 4% free 8930K/9223K, paused 4ms+4ms
05-02 23:47:17.998: A/libc(590): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1)

10条回答
闹够了就滚
2楼-- · 2019-01-22 11:01

I too had this error when using Libgdx for android, and I found out this error is caused by Box2d which uses native code, it is better to look at part of your code which uses Box2d and see if there is any null pointers.

查看更多
Melony?
3楼-- · 2019-01-22 11:14

Same thing happened to me during game development using LibGDX framework for Android, and here's why:

I have 2 screens - GameScreen and BattleScreen. GameScreen is where I move my character on the map. When I have collision with enemy sprite I instantly use game.setScreen(new BattleScreen(this)) and change current screen to BattleScreen. Here's where the Fatal Signal 11 used to happen. At first I thought it had something to do with loading assets, because my asset manager instance was static. I was trying multiple ways of loading them but nothing worked. It turned out I was changing the screen in the wrong place. For my GameScreen I had WorldController and WorldRenderer instance. I was using worldController.update() and worldRenderer.render() inside GameScreen's render(float deltaTime) method. Inside worldController.update() I was checking for collisions and changing screen as soon as I found one with the enemy. It was not good for Android, maybe because it happened between update and render, or it took some time, while update was still running and it lead to conflicts - I don't know. But here is how I fixed it:

  1. I added a boolean flag (false by default) inside WorldController and everytime a collision with enemy happened I was setting it to true
  2. In GameScreen's render() I was checking this flag - if it was true I would change the screen to BattleScreen, otherwise I would update and render GameScreen

Now it works perfectly everytime, no FATAL SIGNAL ERROR 11 whatsoever

Here's my GameScreen's render() method:

@Override
public void render(float deltaTime) {

    if(worldController.isCollisionWithEnemy()) {

        game.setScreen(game.battleScreen);

    } else {

        if(!paused) {
            worldController.update(deltaTime);
        }

        Gdx.gl.glClearColor(57.0f / 255.0f, 181.0f / 225.0f, 115.0f / 255.0f, 1.0f);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        worldRenderer.render();
    }

}
查看更多
再贱就再见
4楼-- · 2019-01-22 11:16

I had this same problem this morning and was able to track it back to accidentally saving an image 800 pixels wide in the drawable-mdpi folder. When I realized what happened I tinkered with it for a second. I tried compressing it hard to see if it was related to file size and it was not. Then I tried saving it again at 650 pixels wide and it worked out of that folder. So somewhere between there is the breaking point for every folder I would guess. Then I put the 800 p wide image in the intended hdpi folder and the 480 p wide in the mdpi and it fixed it.

查看更多
做自己的国王
5楼-- · 2019-01-22 11:17

In my case, it was a null pointer exception inside an onDraw event that prevent the draw to be completed on the canvas. I think is a general error message given when a draw problem ocurr.

查看更多
登录 后发表回答