From 6779af2668b55c06d2ac67a5bac7934848d684a2 Mon Sep 17 00:00:00 2001
From: rtoy <rtoy>
Date: Thu, 29 Jul 2004 16:47:40 +0000
Subject: [PATCH] Some interrupt fixes.  sigill_handler was enabling all
 interrupts in the handler, which seems to be a bad idea since
 interrupt_handle_now has comments about alloc_sap while interrupts are
 disabled.

Not 100% sure this is all right, but everything still appears to work.
---
 lisp/sparc-arch.c | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/lisp/sparc-arch.c b/lisp/sparc-arch.c
index 1bb015f41..da1e65897 100644
--- a/lisp/sparc-arch.c
+++ b/lisp/sparc-arch.c
@@ -1,6 +1,6 @@
 /*
 
- $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/sparc-arch.c,v 1.22 2004/07/07 18:07:53 rtoy Exp $
+ $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/sparc-arch.c,v 1.23 2004/07/29 16:47:40 rtoy Exp $
 
  This code was written as part of the CMU Common Lisp project at
  Carnegie Mellon University, and has been placed in the public domain.
@@ -293,6 +293,7 @@ void handle_allocation_trap(struct sigcontext *context)
   target = 0;
   size = 0;
   
+#if 0
   /*
    * Block all blockable signals.  Need to do this because
    * sigill_handler enables the signals.  When the handler returns,
@@ -302,7 +303,18 @@ void handle_allocation_trap(struct sigcontext *context)
   sigemptyset(&block);
   FILLBLOCKSET(&block);
   sigprocmask(SIG_BLOCK, &block, 0);
-      
+#else
+  /*
+   * Well, maybe not.  sigill_handler probably shouldn't be unblocking
+   * all signals.  So, let's enable just the signals we need.  Since
+   * alloc might call GC, we need to have SIGILL enabled so we can do
+   * allocation.  Do we need more?
+   */
+  sigemptyset(&block);
+  sigaddset(&block, SIGILL);
+  sigprocmask(SIG_UNBLOCK, &block, NULL);
+#endif
+  
   pc = (unsigned int*) SC_PC(context);
   or_inst = pc[-1];
 
@@ -412,7 +424,22 @@ static void sigill_handler(HANDLER_ARGS)
     SAVE_CONTEXT();
 
 #ifdef POSIX_SIGS
+    /*
+     * Do we really want to have the same signals as in the context?
+     * This would typically enable all signals, I think.  But there
+     * are comments in interrupt_handle_now that says we want to
+     * alloc_sap while interrupts are disabled.  The interrupt
+     * handlers that eventually get called from here will re-enable
+     * interrupts at the appropriate time, so we don't do anything
+     * here.
+     *
+     * (I'm guessing here.  I don't really know if this is right or
+     * not, but it doesn't seem to cause harm, and it does seem to be
+     * a bad idea to have interrupts enabled here.)
+     */
+#if 0
     sigprocmask(SIG_SETMASK, &context->uc_sigmask, 0);
+#endif
 #else
     sigsetmask(context->sc_mask);
 #endif
-- 
GitLab