Faulting pthread signal handlers abort
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 26 Aug 2014 23:32:01 +0000 (16:32 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 26 Aug 2014 23:32:01 +0000 (16:32 -0700)
If the handler faults and tries to signal itself, we print the debug info and
abort the process.

Note the sighandler or the process in general can mask or override certain
handlers (like the PF handler) to not do anything.  In which case, the thread
will restart and refault, forever.  That's the process's fault.

user/pthread/pthread.c

index 1b7e848..340417c 100644 (file)
@@ -169,6 +169,12 @@ static void __pthread_signal_and_restart(struct pthread_tcb *pthread,
                                           int signo, int code, void *addr)
 {
        if (!__sigismember(&pthread->sigmask, signo)) {
+               if (pthread->sigdata) {
+                       printf("Pthread sighandler faulted, signal: %d\n", signo);
+                       /* uthread.c already copied out the faulting ctx into the uth */
+                       print_user_context(&pthread->uthread.u_ctx);
+                       exit(-1);
+               }
                struct siginfo info = {0};
                info.si_signo = signo;
                info.si_code = code;