如何处理或prevent致命错误"致命的信号11(SIGSEGV)QUOT; [英] How to handle or prevent the fatal error "Fatal signal 11 (SIGSEGV)"

查看:202
本文介绍了如何处理或prevent致命错误"致命的信号11(SIGSEGV)QUOT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Perhapse我对不同信号的致命错误的幸运。对于今天这是以下内容:

  20 02-05:57:21.827:D / MY_TEST_MESSAGE(4349):Engine.onVisibilityChanged()
02-05 20:57:21.827:D / MY_TEST_MESSAGE(4349):DrawTask#3创建!
02-05 20:57:21.827:D / MY_TEST_MESSAGE(4349):DrawTas#3是工作!
02-05 20:57:21.837:I / BRCM-GR(4349):gralloc_lock]:新的使用0x903
02-05 20:57:21.837:I / BRCM-GR(4349):gralloc_lock]:新的使用0x930
02-05 20:57:21.877:I / BRCM-GR(4349):gralloc_lock]:新的使用0x933
02-05 20:57:21.927:D / dalvikvm(4349):GC_FOR_ALLOC释放1519K,18%免费20612K / 25095K,暂停31毫秒,31毫秒总
02-05 20:57:21.987:I / BRCM-GR(4349):gralloc_lock]:新的使用0x933
02-05 20:57:22.257:D / MY_TEST_MESSAGE(4349):Engine.onVisibilityChanged()
02-05 20:57:22.347:I / BRCM-GR(4349):gralloc_lock]:新的使用0x933
02-05 20:57:22.427:I / BRCM-GR(4349):gralloc_lock]:新的使用0x903
02-05 20:57:22.427:I / BRCM-GR(4349):gralloc_lock]:新的使用0x930
02-05 20:57:22.447:I / BRCM-GR(4349):gralloc_lock]:新的使用0x933
02-05 20:57:22.497:D / MY_TEST_MESSAGE(4349):Engine.onSurfaceDestroyed()
02-05 20:57:22.507:D / MY_TEST_MESSAGE(4349):Engine.onDestroy发布
02-05 20:57:22.517:D / MY_TEST_MESSAGE(4349):WallpaperService.onDestroy()
02-05 20:57:226.27:D / dalvikvm(4349):GC_FOR_ALLOC释放1510K,18%免费20619K / 25095K,暂停18毫秒,总19ms
02-05 20:57:226.27:I / dalvikvm堆(4349):成长堆(frag的情况下),以25.673MB为5242896字节分配
02-05 20:57:22.657:D / dalvikvm(4349):GC_CONCURRENT释放8K,16%免费25731K / 30279K,暂停3毫秒+ 3ms的,总23MS
02-05 20:57:22.727:A / libc的(4349):在0x52905020(code = 2)致命信号11(SIGSEGV),螺纹4376(AsyncTask的#3)

本日志片断说我说,也许错误,当我尝试使用SurfaceHolder实际被破坏的onSurfaceDestroyed()方法发生。

这种状态的用例是:


  1. 开始我的动态壁纸

  2. 在设置按钮preSS

  3. 更改任何设置(或不改变 - 同样的行为)和preSS返回

  4. 立即再次preSS返回

  5. 出错

那么,什么是最多的(4)和(5)?主要的一点是,经过pressing返回上设置屏幕中的onVisualChanged()方法调用preSET动画使用现有持有人及帆布,但接下来马上pressing返回调用onSurfaceDestroyed()方法,使持有人摧毁变化的图像。

@这只是我可以用上面的错误重现一种情况。

@,如果返回的第二pressing将接近状态的动画完成的错误不会发生

所以,我的问题是:


  1. 有没有什么工艺来处理或prevent相比发生错误?

  2. 我怎么能说我的DrawTask持有人不可用,动画应该停止?

  3. 或者,可能有此错误的另一个原因吗


解决方案

不知道,无论是在正确的方式做,但目前我加入3秒睡眠解决了我的问题。因此,在 onSurfaceDestroyed()已更改用:

  @覆盖
    公共无效onSurfaceDestroyed(SurfaceHolder持有人){
        super.onSurfaceDestroyed(保持器);
        Log.d(MY_TEST_MESSAGE,Engine.onSurfaceDestroyed());
        尝试{
             Thread.currentThread()睡眠(500)。
        }
        赶上(例外IE){}
        mVisible = FALSE;
        如果(myDrawTask!= NULL){
            myDrawTask.cancel(假);
        }
    }

这工作没有任何意外的延迟。

Perhapse I am lucky on the fatal error on different signals. For today that was the following:

02-05 20:57:21.827: D/MY_TEST_MESSAGE(4349): Engine.onVisibilityChanged()
02-05 20:57:21.827: D/MY_TEST_MESSAGE(4349): DrawTask #3 is created!
02-05 20:57:21.827: D/MY_TEST_MESSAGE(4349): DrawTas #3 is working!
02-05 20:57:21.837: I/brcm-gr(4349): [gralloc_lock]: new usage 0x903
02-05 20:57:21.837: I/brcm-gr(4349): [gralloc_lock]: new usage 0x930
02-05 20:57:21.877: I/brcm-gr(4349): [gralloc_lock]: new usage 0x933
02-05 20:57:21.927: D/dalvikvm(4349): GC_FOR_ALLOC freed 1519K, 18% free 20612K/25095K, paused 31ms, total 31ms
02-05 20:57:21.987: I/brcm-gr(4349): [gralloc_lock]: new usage 0x933
02-05 20:57:22.257: D/MY_TEST_MESSAGE(4349): Engine.onVisibilityChanged()
02-05 20:57:22.347: I/brcm-gr(4349): [gralloc_lock]: new usage 0x933
02-05 20:57:22.427: I/brcm-gr(4349): [gralloc_lock]: new usage 0x903
02-05 20:57:22.427: I/brcm-gr(4349): [gralloc_lock]: new usage 0x930
02-05 20:57:22.447: I/brcm-gr(4349): [gralloc_lock]: new usage 0x933
02-05 20:57:22.497: D/MY_TEST_MESSAGE(4349): Engine.onSurfaceDestroyed()
02-05 20:57:22.507: D/MY_TEST_MESSAGE(4349): Engine.onDestroy released
02-05 20:57:22.517: D/MY_TEST_MESSAGE(4349): WallpaperService.onDestroy()
02-05 20:57:22.627: D/dalvikvm(4349): GC_FOR_ALLOC freed 1510K, 18% free 20619K/25095K, paused 18ms, total 19ms
02-05 20:57:22.627: I/dalvikvm-heap(4349): Grow heap (frag case) to 25.673MB for 5242896-byte allocation
02-05 20:57:22.657: D/dalvikvm(4349): GC_CONCURRENT freed 8K, 16% free 25731K/30279K, paused 3ms+3ms, total 23ms
02-05 20:57:22.727: A/libc(4349): Fatal signal 11 (SIGSEGV) at 0x52905020 (code=2), thread 4376 (AsyncTask #3)

This log snippet say me that, probably, error occured when I try to use SurfaceHolder that actually is destroyed with the onSurfaceDestroyed() method.

The use case of such state is:

  1. start my Live Wallpaper
  2. press on Settings button
  3. change any of settings (or without changing - the same behaviour) and press Back
  4. immediately press Back again
  5. error occured

So, what is up between (4) and (5)? The main point is that after pressing Back on Settings screen the onVisualChanged() method invokes the preset animation for changing images using available holder and canvas, but next immediate pressing Back invokes onSurfaceDestroyed() method that makes holder destroyed.

@"This is only one situation that I could reproduce with an error above."

@"An error does not occured if second pressing of Back will be near to the state animation finished"

So, my questions are:

  1. Is there any technics to handle or prevent arised error?
  2. How can I say my DrawTask that the holder is unavailable and animation should be stopped?
  3. Or, may be there is another cause of this error?

解决方案

Not sure, whether it was done in correct way, but currently I resolved my issue by adding three seconds sleep. So, the onSurfaceDestroyed() has been changed with:

        @Override
    public void onSurfaceDestroyed(SurfaceHolder holder) {
        super.onSurfaceDestroyed(holder);
        Log.d("MY_TEST_MESSAGE", "Engine.onSurfaceDestroyed()");
        try{
             Thread.currentThread().sleep(500);
        }
        catch(Exception ie){ }
        mVisible = false;
        if (myDrawTask != null) {
            myDrawTask.cancel(false);
        }
    }

It works without any unexpected delays.

这篇关于如何处理或prevent致命错误"致命的信号11(SIGSEGV)QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆