先决条件:ARMv7 设备,Android 平台 4.2.2。
有时我会在通过活页夹与系统服务(一个非常有问题的服务)交互时获得 SIGABRT。堆栈跟踪如下:
#00 pc 000170ac /system/lib/libc.so (__ioctl+8)
#01 pc 0002aa8d /system/lib/libc.so (ioctl+16)
#02 pc 00016ba1 /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+132)
#03 pc 0001709d /system/lib/libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel*, int*)+44)
#04 pc 000172b7 /system/lib/libbinder.so (android::IPCThreadState::transact(int, unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+114)
#05 pc 00014a3b /system/lib/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+34)
__ioctl 解析为以下汇编代码:
000170a4 <__ioctl>:
170a4: e92d0090 push {r4, r7}
170a8: e3a07036 mov r7, #54 ; 0x36
170ac: ef000000 svc 0x00000000
170b0: e8bd0090 pop {r4, r7}
170b4: e1b00000 movs r0, r0
170b8: 512fff1e bxpl lr
170bc: ea0093a6 b 3bf5c
堆栈转储由信号 6 (SIGABRT)、代码 -6 (SI_KILL) 触发,故障地址为 0x304、0x330、0x33A(有时会有所不同,我什至不确定它是否真的是任何地址中的地址空格而不是错误代码或标志组合)。
我不知道信号可能表明什么,即它是否是
- 驱动程序错误(但为什么它以如此奇怪的方式而不是返回值传递?)
- 未拦截的驱动程序错误(即使没有内核恐慌也可能吗?);
- 内核故障(在驱动程序调用之外,可能与驱动程序无关);
- 一个损坏的中断向量(那么为什么不是 SIGSEGV 或 SIGILL?);
- 在主管模式下收到 SIGQUIT(Dalvik 堆栈跟踪信号)的结果。
在最后一种情况下,我收回我的惊讶并继续调查阻塞调用冻结原因(被调用进程中的死锁?)。可能,我可以构建一个测试应用程序来重现这个特定的先决条件,但这需要时间。
我在网络上发现了许多看起来相似的痕迹和错误报告,表明问题不是特定于设备或供应商的(尽管可能特定于平台版本)。
与之交互的确切服务也不重要。
PS日志猫:
03-21 16:21:22.933 772 831 I InputDispatcher: Application is not responding: Window{41000dd8 u0 my.application.package/my.application.package.MyActivity}. It has been 5008.3ms since event, 5005.7ms since wait started. Reason: Waiting because the touched window has not finished processing the input events that were previously delivered to it.
03-21 16:21:22.943 772 831 I WindowManager: Input event dispatching timed out sending to my.application.package/my.application.package.MyActivity
03-21 16:21:23.163 772 831 I Process : Sending signal. PID: 16195 SIG: 3
03-21 16:21:23.163 16195 16200 I dalvikvm: threadid=3: reacting to signal 3
03-21 16:21:23.263 16195 16200 I dalvikvm: Wrote stack traces to '/data/anr/traces.txt'
03-21 16:21:23.273 772 831 E ActivityManager: ANR in my.application.package (my.application.package/my.application.package.MyActivity)
03-21 16:21:23.273 772 831 E ActivityManager: Reason: keyDispatchingTimedOut
03-21 16:21:23.273 772 831 E ActivityManager: Load: 0.0 / 0.0 / 0.0
03-21 16:21:23.273 772 831 E ActivityManager: CPU usage from 18140ms to 0ms ago:
-- CPU usage dump, nothing unusual --
03-21 16:21:23.273 772 831 E ActivityManager: 61% TOTAL: 33% user + 27% kernel + 0% iowait + 0.8% softirq
03-21 16:21:23.273 772 831 E ActivityManager: CPU usage from 5686369ms to 5686369ms ago with 0% awake:
03-21 16:21:23.273 772 831 E ActivityManager: 0% TOTAL: 0% user + 0% kernel
03-21 16:21:23.283 772 831 I Process : Sending signal. PID: 16195 SIG: 6
03-21 16:21:23.283 16195 16195 F libc : Fatal signal 6 (SIGABRT) at 0x00000304 (code=0), thread 16195 (my.application.package)
-- and then the stack dump --