From ca9a0712b89eee017c2a40056c101d86c1f7d02f Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Thu, 8 Mar 2012 11:14:37 -0800 Subject: [PATCH] Re-throw signals If we catch a fatal signal that won't automatically re-throw when the thread resumes, re-throw it manually. (Common examples are SIGPIPE and the SIGFPE from integer division by zero.) Change-Id: I329e6d4db907047c555957b42cbd09c50fc808e7 --- linker/debugger.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/linker/debugger.c b/linker/debugger.c index 40411b11a..899a5b2e7 100644 --- a/linker/debugger.c +++ b/linker/debugger.c @@ -40,6 +40,8 @@ #include #include +extern int tgkill(int tgid, int tid, int sig); + void notify_gdb_of_libraries(); #define RETRY_ON_EINTR(ret,cond) \ @@ -181,6 +183,24 @@ void debugger_signal_handler(int n, siginfo_t* info, void* unused) /* remove our net so we fault for real when we return */ signal(n, SIG_DFL); + + /* + * These signals are not re-thrown when we resume. This means that + * crashing due to (say) SIGPIPE doesn't work the way you'd expect it + * to. We work around this by throwing them manually. We don't want + * to do this for *all* signals because it'll screw up the address for + * faults like SIGSEGV. + */ + switch (n) { + case SIGABRT: + case SIGFPE: + case SIGPIPE: + case SIGSTKFLT: + (void) tgkill(getpid(), gettid(), n); + break; + default: // SIGILL, SIGBUS, SIGSEGV + break; + } } void debugger_init()