[project @ 2002-07-02 12:24:48 by simonmar]
authorsimonmar <unknown>
Tue, 2 Jul 2002 12:24:48 +0000 (12:24 +0000)
committersimonmar <unknown>
Tue, 2 Jul 2002 12:24:48 +0000 (12:24 +0000)
Don't install a SIGFPE handler: this causes us to go into an infinite
loop on a divide by zero on some systems (BSD, but not Linux it
seems).  I don't think we really ought to be ignoring SIGFPE: for
floating point exceptions, the system usually has a way to request
that operations generate exceptional values rather than signals (this
is the required IEEE behaviour), and for integral division we should
really check beforehand for division by zero (we don't yet).

ghc/rts/Signals.c

index 9edefbb..b94ad6d 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Signals.c,v 1.24 2002/03/26 23:51:27 sof Exp $
+ * $Id: Signals.c,v 1.25 2002/07/02 12:24:48 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -363,12 +363,24 @@ initDefaultHandlers()
     }
 
     // install the SIGFPE handler
+
+    // In addition to handling SIGINT, also handle SIGFPE by ignoring it.
+    // Apparently IEEE requires floating-point exceptions to be ignored by
+    // default, but alpha-dec-osf3 doesn't seem to do so.
+
+    // Commented out by SDM 2/7/2002: this causes an infinite loop on
+    // some architectures when an integer division by zero occurs: we
+    // don't recover from the floating point exception, and the
+    // program just generates another one immediately.
+#if 0
     action.sa_handler = SIG_IGN;
     sigemptyset(&action.sa_mask);
     action.sa_flags = 0;
     if (sigaction(SIGFPE, &action, &oact) != 0) {
        prog_belch("warning: failed to install SIGFPE handler");
     }
+#endif
+
 #ifdef alpha_TARGET_ARCH
     ieee_set_fp_control(0);
 #endif