On Tue, 10 May 2011 00:14:42 -0300, David Bremner <brem...@debian.org> wrote:
> On Mon, 9 May 2011 06:56:48 -0600, Matthew Flatt <mfl...@cs.utah.edu> wrote:
> > Maybe someone decided that SIGSEGV is the right signal after all for an
> > mprotect() violation (which Rackets catches as a write barrier) instead
> > of SIGBUS.
> 
> I suppose there is a good reason not to catch both signals?
> 
> David

I don't claim to understand all the implications yet, but the following
patch seems to work, i.e. catching both SIGSEGV and SIGBUS with the same
handler.

>From 748f1dd0b6d387bc0577075e56afde3958c08f86 Mon Sep 17 00:00:00 2001
From: David Bremner <brem...@debian.org>
Date: Tue, 10 May 2011 22:50:04 -0300
Subject: [PATCH] on GNU/kFreeBSD, catch both SIGBUS and SIGSEGV from mprotect

---
 src/racket/gc2/sighand.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/racket/gc2/sighand.c b/src/racket/gc2/sighand.c
index 5b4b991..87e02aa 100644
--- a/src/racket/gc2/sighand.c
+++ b/src/racket/gc2/sighand.c
@@ -134,10 +134,13 @@ void fault_handler(int sn, siginfo_t *si, void *ctx)
     abort();
 }
 #  define NEED_SIGACTION
-#  if (defined(__FreeBSD__) && (__FreeBSD_version < 700000)) || defined(__FreeBSD_kernel__)
+#  if (defined(__FreeBSD__) && (__FreeBSD_version < 700000)) 
 #    define USE_SIGACTON_SIGNAL_KIND SIGBUS
 #  else
 #    define USE_SIGACTON_SIGNAL_KIND SIGSEGV
+#    ifdef __FreeBSD_kernel__
+#	define ALSO_CATCH_SIGBUS
+#    endif
 #  endif
 #endif
 
@@ -230,6 +233,9 @@ static void initialize_signal_handler(GCTYPE *gc)
     act.sa_flags |= SA_ONSTACK;
 #  endif
     sigaction(USE_SIGACTON_SIGNAL_KIND, &act, &oact);
+#  ifdef ALSO_CATCH_SIGBUS
+    sigaction(SIGBUS, &act, &oact); 
+#  endif
   }
 # endif
 # ifdef NEED_SIGWIN
@@ -263,6 +269,9 @@ static void remove_signal_handler(GCTYPE *gc)
     sigemptyset(&act.sa_mask);
     act.sa_flags = SA_SIGINFO;
     sigaction(USE_SIGACTON_SIGNAL_KIND, &act, &oact);
+#  ifdef ALSO_CATCH_SIGBUS
+    sigaction(SIGBUS, &act, &oact); 
+#  endif
   }
 # endif
 # ifdef NEED_SIGWIN
-- 
1.7.4.4

_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev

Reply via email to