* Add debugging tool to keep trace of signal delivery in a history.
authorChris Hanson <org/chris-hanson/cph>
Tue, 15 Feb 1994 04:23:49 +0000 (04:23 +0000)
committerChris Hanson <org/chris-hanson/cph>
Tue, 15 Feb 1994 04:23:49 +0000 (04:23 +0000)
  The code to do this is disabled unless DEBUG_SIGNAL_DELIVERY is
  defined.

* Define alternate version of `signal' to work around bug in Sony
  NEWS-OS 5.0.2.  Scheme doesn't use `signal' on that system, but libc
  does.

* Eliminate incorrect extra binding of signal handler for SIGIOT.

v7/src/microcode/uxsig.c
v7/src/microcode/uxsig.h

index ac8575fcb15b996759c8c16229a01ac70e878b27..cb485ddaa29a4b1fcff214f8bf8abcdc84af606a 100644 (file)
@@ -1,8 +1,8 @@
 /* -*-C-*-
 
-$Id: uxsig.c,v 1.27 1993/08/28 22:46:42 gjr Exp $
+$Id: uxsig.c,v 1.28 1994/02/15 04:23:41 cph Exp $
 
-Copyright (c) 1990-1993 Massachusetts Institute of Technology
+Copyright (c) 1990-94 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -178,6 +178,78 @@ DEFUN (activate_handler, (signo, handler),
   INSTALL_HANDLER (signo, handler) ;
 }
 \f
+/* Signal Debugging */
+
+#ifdef DEBUG_SIGNAL_DELIVERY
+
+int signal_history [256];
+int * signal_history_pointer;
+
+static void
+DEFUN_VOID (initialize_signal_debugging)
+{
+  int * scan = (&signal_history[0]);
+  int * end = (scan + (sizeof (signal_history)));
+  signal_history_pointer = scan;
+  while (scan < end)
+    (*scan++) = 0;
+}
+
+static void
+DEFUN (record_signal_delivery, (signo), int signo)
+{
+  block_signals ();
+  (*signal_history_pointer++) = signo;
+  if (signal_history_pointer >= (& (signal_history [sizeof (signal_history)])))
+    signal_history_pointer = (&signal_history[0]);
+  unblock_signals ();
+}
+
+#else /* not DEBUG_SIGNAL_DELIVERY */
+
+#define initialize_signal_debugging()
+#define record_signal_delivery(signo)
+
+#endif /* not DEBUG_SIGNAL_DELIVERY */
+
+#if defined(sonyrisc) && defined(_SYSV4)
+/* Sony NEWS-OS 5.0.2 has a nasty bug because `sigaction' maintains a
+   table which contains the signal handlers, and passes
+   `sigaction_handler' to the kernel in place of any handler's
+   address.  Unfortunately, `signal' doesn't know about this table, so
+   it returns `sigaction_handler' as its value, which can subsequently
+   get passed back to `sigaction' and stored in the table.  Once
+   stored in the table, this causes an infinite recursion, which kills
+   the process (with SIGSEGV) when the stack exceeds the allowable
+   amount of virtual memory.
+
+   This problem would not be an issue, because Scheme deliberately
+   doesn't mix the use of `sigaction' with `signal', except that the
+   last release of 5.0.2 (baseline 31.1) calls `signal' from
+   `grantpt'.  So, the following patch overrides the built-in version
+   of `signal' with one that coexists safely with `sigaction'.  */
+
+Tsignal_handler
+DEFUN (signal, (signo, handler),
+       int signo AND
+       Tsignal_handler handler)
+{
+  struct sigaction act;
+  struct sigaction oact;
+
+  (act . sa_handler) = handler;
+  UX_sigemptyset (& (act . sa_mask));
+  (act . sa_flags) = (SA_RESETHAND | SA_NODEFER);
+  if (handler == SIG_IGN)
+    (act . sa_flags) |= SA_NOCLDWAIT;
+  if ((UX_sigaction (signo, (&act), (&oact))) < 0)
+    return (SIG_ERR);
+  else
+    return (oact . sa_handler);
+}
+
+#endif /* sonyrisc && _SYSV4 */
+\f
 /* Signal Descriptors */
 
 enum dfl_action { dfl_terminate, dfl_ignore, dfl_stop };
@@ -583,6 +655,7 @@ DEFUN_VOID (UX_initialize_signals)
   stop_signal_hook = 0;
   subprocess_death_hook = 0;
   initialize_signal_descriptors ();
+  initialize_signal_debugging ();
   bind_handler (SIGINT,                sighnd_control_g);
   bind_handler (SIGFPE,                sighnd_fpe);
   bind_handler (SIGALRM,       sighnd_timer);
@@ -616,7 +689,6 @@ DEFUN_VOID (UX_initialize_signals)
         bind_handler (SIGIOT,   sighnd_control_x);
       else
         bind_handler (SIGIOT,  sighnd_software_trap);
-      bind_handler (SIGIOT,    sighnd_software_trap);
       bind_handler (SIGEMT,    sighnd_software_trap);
       bind_handler (SIGSYS,    sighnd_software_trap);
       bind_handler (SIGABRT,   sighnd_software_trap);
index 21e04529ad70cdf7d99608b68fcaae8341331e71..881d2f4f746047c476d5990254fa43375c7c0135 100644 (file)
@@ -1,8 +1,8 @@
 /* -*-C-*-
 
-$Id: uxsig.h,v 1.2 1993/08/28 23:08:57 gjr Exp $
+$Id: uxsig.h,v 1.3 1994/02/15 04:23:49 cph Exp $
 
-Copyright (c) 1993 Massachusetts Institute of Technology
+Copyright (c) 1993-94 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -70,6 +70,7 @@ DEFUN (name, (signo, info, pscp),                                     \
   int STD_HANDLER_abortp;                                              \
   DECLARE_FULL_SIGCONTEXT (scp);                                       \
   INITIALIZE_FULL_SIGCONTEXT (pscp, scp);                              \
+  record_signal_delivery (signo);                                      \
   STD_HANDLER_abortp = (enter_interruption_extent ());                 \
   statement;                                                           \
   if (STD_HANDLER_abortp)                                              \