我用C代码调试我的Android项目,logcat消息显示:
I/DEBUG (13509): backtrace:
I/DEBUG (13509): #00 pc 000106dc /system/lib/libc.so (dlmalloc+1463)
I/DEBUG (13509): #01 pc 0000cf3f /system/lib/libc.so (malloc+10)
I/DEBUG (13509): #02 pc 00011d0d /system/lib/libutils.so (android::SharedBuffer::alloc(unsigned int)+8)
I/DEBUG (13509): #03 pc 00014cf7 /system/lib/libutils.so (android::VectorImpl::setCapacity(unsigned int)+22)
I/DEBUG (13509): #04 pc 0007fd79 /system/lib/libandroid_runtime.so (android::TextLayoutValue::TextLayoutValue(unsigned int)+108)
I/DEBUG (13509): #05 pc 000811a9 /system/lib/libandroid_runtime.so (android::TextLayoutCache::getValue(SkPaint const*, unsigned short const*, int, int, int, int)+184)
I/DEBUG (13509): #06 pc 00081589 /system/lib/libandroid_runtime.so (android::TextLayoutEngine::getValue(SkPaint const*, unsigned short const*, int, int, int, int)+36)
I/DEBUG (13509): #07 pc 0007f799 /system/lib/libandroid_runtime.so (android::TextLayout::getTextRunAdvances(SkPaint*, unsigned short const*, int, int, int, int, float*, float*)+42)
I/DEBUG (13509): #08 pc 0007c60d /system/lib/libandroid_runtime.so
I/DEBUG (13509): #09 pc 0007c7f9 /system/lib/libandroid_runtime.so
I/DEBUG (13509): #10 pc 0001e690 /system/lib/libdvm.so (dvmPlatformInvoke+112)
I/DEBUG (13509): #11 pc 0005100f /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+426)
I/DEBUG (13509): #12 pc 00027aa0 /system/lib/libdvm.so
I/DEBUG (13509): #13 pc 0002ce84 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+232)
I/DEBUG (13509): #14 pc 000674bf /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+374)
I/DEBUG (13509): #15 pc 0007066f /system/lib/libdvm.so
I/DEBUG (13509): #16 pc 00027aa0 /system/lib/libdvm.so
I/DEBUG (13509): #17 pc 0002ce84 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+232)
I/DEBUG (13509): #18 pc 000671a1 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+272)
I/DEBUG (13509): #19 pc 0004d2d7 /system/lib/libdvm.so
I/DEBUG (13509): #20 pc 0004d391 /system/lib/libandroid_runtime.so
I/DEBUG (13509): #21 pc 0004e22d /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+540)
I/DEBUG (13509): #22 pc 00000e67 /system/bin/app_process
I/DEBUG (13509): #23 pc 000128b3 /system/lib/libc.so (__libc_init+38)
I/DEBUG (13509): #24 pc 00000b74 /system/bin/app_process
消息告诉我问题是malloc,似乎这个bug来自libandroid_runtim。
如何知道我项目中的问题?因为该消息不显示我的代码位置,所以包括java和c。
请帮助我解决这个问题。这让我很烦。非常感谢。
答案 0 :(得分:1)
你有一个NULL取消引用(这是0x00000000指示的)。因为它在malloc中,这可能意味着你通过在信号之前的某个时间写入malloc的返回区域来破坏内存分配器的内部结构。我建议使用valgrind来检测那个确切的点,我认为它可以在Android上用一些功夫。