1.线程调试mutex问题分析
1.打印线程号、进程号、线程名字
#include <sys/syscall.h>
#include <sys/prctl.h>
int tid = syscall(SYS_gettid);
int pid = syscall(SYS_getpid);
char name[32];
prctl(PR_GET_NAME,name);
2.打印调用堆栈
head file
#include <utils/CallStack.h>
cpp file
Plugin::relese(void)
{
android::CallStack stack("test");
}
file
#debug stack
LOCAL_C_INCLUDES += $(TOP)/system/core/libutils/include
LOCAL_SHARED_LIBRARIES += libutilscallstack
3.打印 AEE_AED backtrace
错误log
05-18 08:33:45.907 I/AEE_AED ( 2416): backtrace:
05-18 08:33:45.907 I/AEE_AED ( 2416): #00 pc 0001cc86 /system/lib/libc.so (abort+58)
05-18 08:33:45.907 I/AEE_AED ( 2416): #01 pc 00064553 /system/lib/libc.so (__fortify_fatal(char const*, ...)+26)
05-18 08:33:45.907 I/AEE_AED ( 2416): #02 pc 00063d55 /system/lib/libc.so (HandleUsingDestroyedMutex(pthread_mutex_t*, char const*)+20)
05-18 08:33:45.907 I/AEE_AED ( 2416): #03 pc 00063c83 /system/lib/libc.so (pthread_mutex_lock+214)
05-18 08:33:45.908 I/AEE_AED ( 2416): #04 pc 00010cd5 /vendor/lib/libmtkcam_imgbuf.so
05-18 08:33:45.908 I/AEE_AED ( 2416): #05 pc 00010edb /vendor/lib/libmtkcam_imgbuf.so
05-18 08:33:45.908 I/AEE_AED ( 2416): #06 pc 000499ab /vendor/lib/libcam.iopipe.so
05-18 08:33:45.908 I/AEE_AED ( 2416): #07 pc 0004926b /vendor/lib/libcam.iopipe.so
打印so库对应的函数与文件的命令如下(随意写了个)
1. cd out/target/product/xxxxx/symbols/vendor/lib64
2. addr2line -f -e libcam.iopipe.so 49139
问题分析:
--------- beginning of crash
05-18 08:33:45.428 F/libc ( 445): FORTIFY: pthread_mutex_lock called on a destroyed mutex (0xa6f2f608)
E/MtkCam/ImgBuf( 445): BaseImageBuffer::~BaseImageBuffer()!!!!!!!!!!!!!! this:0xa6f2f600 mLockMtx:0xa6f2f608 name:MDP@CapPipe tid:2388 pid:445 ~BaseImageBuffer 89
05-18 08:33:45.427 E/MtkCam/ImgBuf( 445): index:0 this:0xa6f2f600 mLockMtx:0xa6f2f608 name:YUV@CapPipe tid:2387 pid:445 getBufOffsetInBytes 395
05-18 08:33:45.427 I/ULog ( 445): R AppRequest:365 M[CameraDevice:187001] + :mtkcam-dev3 #720
--------- beginning of crash
05-18 08:33:45.428 F/libc ( 445): FORTIFY: pthread_mutex_lock called on a destroyed mutex (0xa6f2f608)
其中YUV@CapPipe 线程的 mutex 被 MDP@CapPipe 释放。
到此为止就大概确定了问题的位置,具体不同的问题需要不同的分析,这里就不在叙述。
因篇幅问题不能全部显示,请点此查看更多更全内容