[llvm-commits] [llvm] r66330 - /llvm/trunk/lib/System/Unix/Signals.inc

Chris Lattner sabre at nondot.org
Sat Mar 7 00:15:47 PST 2009


Author: lattner
Date: Sat Mar  7 02:15:47 2009
New Revision: 66330

URL: http://llvm.org/viewvc/llvm-project?rev=66330&view=rev
Log:
When a crash signal is delivered do two things: remove all of our
signal handlers to prevent reentrance on unrelated things (a sigabort
where the handle bus errors) also, clear the signal mask so that the
signal doesn't infinitely reissue.  This fixes rdar://6654827 -
Crash causes clang to loop


Modified:
    llvm/trunk/lib/System/Unix/Signals.inc

Modified: llvm/trunk/lib/System/Unix/Signals.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Signals.inc?rev=66330&r1=66329&r2=66330&view=diff

==============================================================================
--- llvm/trunk/lib/System/Unix/Signals.inc (original)
+++ llvm/trunk/lib/System/Unix/Signals.inc Sat Mar  7 02:15:47 2009
@@ -55,13 +55,23 @@
 static const int *const KillSigsEnd =
   KillSigs + sizeof(KillSigs) / sizeof(KillSigs[0]);
 
-// SignalHandler - The signal handler that runs...
+static void UnregisterHandler(int Signal) {
+   signal(Signal, SIG_DFL); 
+}
+
+
+// SignalHandler - The signal handler that runs.
 static RETSIGTYPE SignalHandler(int Sig) {
   // Restore the signal behavior to default, so that the program actually
   // crashes when we return and the signal reissues.  This also ensures that if
   // we crash in our signal handler that the program will terminate immediately
   // instead of recursing in the signal handler.
-  signal(Sig, SIG_DFL);
+  std::for_each(KillSigs, KillSigsEnd, UnregisterHandler);
+
+  // Unmask all potentially blocked kill signals.
+  sigset_t SigMask;
+  sigfillset(&SigMask);
+  sigprocmask(SIG_UNBLOCK, &SigMask, 0);
 
   if (FilesToRemove != 0)
     while (!FilesToRemove->empty()) {
@@ -86,12 +96,11 @@
 }
 
 // Just call signal
-static void RegisterHandler(int Signal) { 
-  signal(Signal, SignalHandler); 
+static void RegisterHandler(int Signal) {
+   signal(Signal, SignalHandler); 
 }
 
 
-
 void sys::SetInterruptFunction(void (*IF)()) {
   InterruptFunction = IF;
   RegisterHandler(SIGINT);





More information about the llvm-commits mailing list