简体   繁体   中英

segmentation fault handler crashes with segmentation fault

I am using arm machine and segmentation handler sometimes crashes while obtaining crash context address:

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
}

This is how handler is setup:

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
}

Is there any possible way to check if arm_pc filed in sigcontext is readable, so I can avoid the crash in crash handler?

问题是内存损坏在处理程序中执行操作

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM