void fault_handler(int sn, struct siginfo *si, void *ctx) { void *p = si->si_addr; /* quick access to SIGSEGV info in GDB */ int c = si->si_code; #ifdef MZ_USE_PLACES int m = 0; #endif if (si->si_code != SEGV_ACCERR) { /*SEGV_MAPERR*/ if (c == SEGV_MAPERR) { printf("SIGSEGV MAPERR si_code %i fault on addr %p\n", c, p); } if (c == 0 ) { /* I have now idea why this happens on linux */ /* supposedly its coming from the user via kill */ /* so just ignore it. */ printf("SIGSEGV SI_USER SI_CODE %i fault on addr %p\n", c, p); printf("pid %i uid %i thread %lx\n", si->si_pid, si->si_uid, mz_proc_thread_self()); return; } if (c == 128 ) { printf("SIGSEGV SI_KERNEL SI_CODE %i fault on addr %p sent by kernel\n", c, p); } #if WAIT_FOR_GDB launchgdb(); #endif abort(); } if (!designate_modified(p)) { if (si->si_code == SEGV_ACCERR) { #ifdef MZ_USE_PLACES if(pagemap_find_page(MASTERGC->page_maps, p)) { m = 1; printf("ADDR %p OWNED BY MASTER %i\n", p, m); } #endif printf("SIGSEGV SEGV_ACCERR SI_CODE %i fault on %p\n", c, p); } else { printf("SIGSEGV ???? SI_CODE %i fault on %p\n", c, p); } abort(); } # define NEED_SIGSTACK # define NEED_SIGACTION # define USE_SIGACTON_SIGNAL_KIND SIGSEGV }
void fault_handler(int sn, siginfo_t *si, void *ctx) { void *p = si->si_addr; /* quick access to SIGSEGV info in GDB */ int c = si->si_code; #ifdef MZ_USE_PLACES int m = 0; #endif if (si->si_code != SEGV_ACCERR) { /*SEGV_MAPERR*/ if (c == SEGV_MAPERR) { printf("SIGSEGV MAPERR si_code %i fault on addr %p\n", c, p); /* SIGSEGV MAPERRs are invalid addresses. Possible reasons: An object is prematurely freed because it isn't getting marked correctly An unsafe operation was used incorrectly The stack grew beyond its bounds. */ } if (c == 0) { /* I have no idea why this happens on linux */ /* supposedly its coming from the user via kill */ /* so just ignore it. It appears when */ /* running w/ places in GDB */ printf("SIGSEGV SI_USER SI_ERRNO %i fault on addr %p\n", si->si_errno, p); #ifdef MZ_USE_PLACES printf("pid %i uid %i thread %lx\n", si->si_pid, si->si_uid, mz_proc_thread_self()); #else printf("pid %i uid %i\n", si->si_pid, si->si_uid); #endif return; } if (c == 128) { printf("SIGSEGV SI_KERNEL SI_ERRNO %i fault on addr %p\n", si->si_errno, p); } #if WAIT_FOR_GDB launchgdb(); #endif abort(); } if (!designate_modified(p)) { if (si->si_code == SEGV_ACCERR) { #ifdef MZ_USE_PLACES if(pagemap_find_page(MASTERGC->page_maps, p)) { m = 1; printf("ADDR %p OWNED BY MASTER %i\n", p, m); } #endif printf("SIGSEGV SEGV_ACCERR SI_CODE %i fault on %p\n", c, p); } else { printf("SIGSEGV ???? SI_CODE %i fault on %p\n", c, p); } #if WAIT_FOR_GDB launchgdb(); #endif abort(); } # define NEED_SIGSTACK # define NEED_SIGACTION # define USE_SIGACTON_SIGNAL_KIND SIGSEGV }