Writing siginfo handlers will help you get the culprit virtual address which causes the problem. See the following handy code.
======================================= struct sigaction action; action.sa_sigaction = my_handler; action.sa_flags = SA_RESTART | SA_SIGINFO | SA_RESETHAND; if(sigaction(SIGBUS,&action,NULL)<0) { printf("Cannot register handler\n"); } HANDLER: void my_handler(int sig,siginfo_t *siginfo,void *ucontext){ if(sig == SIGBUS){ printf("SIGBUS Caught\n"); switch(siginfo->si_code){ case BUS_ADRALN: printf("SIGBUS due to address alignment at %x\n",siginfo->si_addr); break; case BUS_ADRERR: printf("SIGBUS due to BUS_ADRERR%08lx\n",siginfo->si_addr); break; case BUS_OBJERR: printf("SIGBUS due to hardware\n"); } qCheers! V.
No comments:
Post a Comment