我正在使用arm机器和分段处理程序有时会在获取崩溃上下文地址时崩溃:
void crit_err_hdlr(int sig_num, siginfo_t * info, void * ucontext)
{
uintptr_t fault_address = NULL;
struct sigcontext *ctx = &(((ucontext_t*)ucontext)->uc_mcontext);
fault_address = ctx->arm_pc;
//after reading ctx->arm_pc it crashes
}
这就是处理程序的设置方式:
struct sigaction sigact = { 0 };
sigact.sa_sigaction = crit_err_hdlr;
sigact.sa_flags = SA_SIGINFO | SA_RESTART;
if (sigaction(SIGSEGV, &sigact, (struct sigaction *)NULL) != 0)
{
//error, bail out
}
有没有办法检查sigcontext中的arm_pc是否可读,所以我可以避免崩溃处理程序崩溃?
答案 0 :(得分:1)
问题是处理程序内部执行操作的内存损坏