1.0.10.4: Use variable for SIG_MEMORY_FAULT on FreeBSD
authorNIIMI Satoshi <sa2c@users.sourceforge.net>
Wed, 26 Sep 2007 11:42:32 +0000 (11:42 +0000)
committerNIIMI Satoshi <sa2c@users.sourceforge.net>
Wed, 26 Sep 2007 11:42:32 +0000 (11:42 +0000)
When SIGBUS is signalled on FreeBSD 7, or SIGSEGV is signalled on
FreeBSD 6 or earlier, it's very hard to debug if both of the signals
are hooked for GC.

Instead to hook both signals, define SIG_MEMORY_FAULT as variable
and set it at startup.

src/runtime/bsd-os.c
src/runtime/bsd-os.h
src/runtime/interrupt.c
version.lisp-expr

index b932fd6..e764c3e 100644 (file)
@@ -242,13 +242,6 @@ os_install_interrupt_handlers(void)
                                                  (__siginfohandler_t *)
 #endif
                                                  memory_fault_handler);
                                                  (__siginfohandler_t *)
 #endif
                                                  memory_fault_handler);
-#ifdef SIG_MEMORY_FAULT2
-    undoably_install_low_level_interrupt_handler(SIG_MEMORY_FAULT2,
-#ifdef LISP_FEATURE_FREEBSD
-                                                 (__siginfohandler_t *)
-#endif
-                                                 memory_fault_handler);
-#endif
 #endif
 
 #ifdef LISP_FEATURE_SB_THREAD
 #endif
 
 #ifdef LISP_FEATURE_SB_THREAD
@@ -289,10 +282,6 @@ os_install_interrupt_handlers(void)
     SHOW("os_install_interrupt_handlers()/bsd-os/!defined(GENCGC)");
     undoably_install_low_level_interrupt_handler(SIG_MEMORY_FAULT,
                                                  sigsegv_handler);
     SHOW("os_install_interrupt_handlers()/bsd-os/!defined(GENCGC)");
     undoably_install_low_level_interrupt_handler(SIG_MEMORY_FAULT,
                                                  sigsegv_handler);
-#ifdef SIG_MEMORY_FAULT2
-    undoably_install_low_level_interrupt_handler(SIG_MEMORY_FAULT2,
-                                                 sigsegv_handler);
-#endif
 }
 
 #endif /* defined GENCGC */
 }
 
 #endif /* defined GENCGC */
@@ -375,8 +364,19 @@ _socket(int domain, int type, int protocol)
 #endif /* __NetBSD__ */
 
 #ifdef __FreeBSD__
 #endif /* __NetBSD__ */
 
 #ifdef __FreeBSD__
+extern int getosreldate(void);
+
+int sig_memory_fault;
+
 static void freebsd_init()
 {
 static void freebsd_init()
 {
+    /* Memory fault signal on FreeBSD was changed from SIGBUS to
+     * SIGSEGV. */
+    if (getosreldate() < 700004)
+        sig_memory_fault = SIGBUS;
+    else
+        sig_memory_fault = SIGSEGV;
+
     /* Quote from sbcl-devel (NIIMI Satoshi): "Some OSes, like FreeBSD
      * 4.x with GENERIC kernel, does not enable SSE support even on
      * SSE capable CPUs". Detect this situation and skip the
     /* Quote from sbcl-devel (NIIMI Satoshi): "Some OSes, like FreeBSD
      * 4.x with GENERIC kernel, does not enable SSE support even on
      * SSE capable CPUs". Detect this situation and skip the
@@ -441,8 +441,6 @@ futex_wake(int *lock_word, int n)
 #define KERN_PROC_PATHNAME 12
 #endif
 
 #define KERN_PROC_PATHNAME 12
 #endif
 
-extern int getosreldate(void);
-
 char *
 os_get_runtime_executable_path()
 {
 char *
 os_get_runtime_executable_path()
 {
index 2324514..f1669d6 100644 (file)
@@ -53,7 +53,6 @@ typedef ucontext_t os_context_t;
  * step flag bit by messing with the flags stored in a signal context,
  * so we need to implement single stepping in a more roundabout way. */
 #define CANNOT_GET_TO_SINGLE_STEP_FLAG
  * step flag bit by messing with the flags stored in a signal context,
  * so we need to implement single stepping in a more roundabout way. */
 #define CANNOT_GET_TO_SINGLE_STEP_FLAG
-#define SIG_MEMORY_FAULT SIGSEGV
 /* Sometime in late 2005 FreeBSD was changed to signal SIGSEGV instead
  * of SIGBUS for memory faults, as required by POSIX. In order to
  * support both new and old FreeBSD at the same time, both signals are
 /* Sometime in late 2005 FreeBSD was changed to signal SIGSEGV instead
  * of SIGBUS for memory faults, as required by POSIX. In order to
  * support both new and old FreeBSD at the same time, both signals are
@@ -62,7 +61,11 @@ typedef ucontext_t os_context_t;
  * quaint memories, feel free to delete this hack (and any code that's
  * #ifdef SIG_MEMORY_FAULT2'ed). -- JES, 2005-12-30
  */
  * quaint memories, feel free to delete this hack (and any code that's
  * #ifdef SIG_MEMORY_FAULT2'ed). -- JES, 2005-12-30
  */
-#define SIG_MEMORY_FAULT2 SIGBUS
+/* Hooking both SIGBUS and SIGSEGV causes troubles on some situation,
+ * so use a variable.
+ */
+extern int sig_memory_fault;
+#define SIG_MEMORY_FAULT (sig_memory_fault)
 
 #define SIG_INTERRUPT_THREAD (SIGINFO)
 #define SIG_STOP_FOR_GC (SIGUSR1)
 
 #define SIG_INTERRUPT_THREAD (SIGINFO)
 #define SIG_STOP_FOR_GC (SIGUSR1)
index d995142..c702e58 100644 (file)
@@ -1192,9 +1192,6 @@ undoably_install_low_level_interrupt_handler (int signal,
         | (sigaction_nodefer_works ? SA_NODEFER : 0);
 #ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
     if((signal==SIG_MEMORY_FAULT)
         | (sigaction_nodefer_works ? SA_NODEFER : 0);
 #ifdef LISP_FEATURE_C_STACK_IS_CONTROL_STACK
     if((signal==SIG_MEMORY_FAULT)
-#ifdef SIG_MEMORY_FAULT2
-       || (signal==SIG_MEMORY_FAULT2)
-#endif
 #ifdef SIG_INTERRUPT_THREAD
        || (signal==SIG_INTERRUPT_THREAD)
 #endif
 #ifdef SIG_INTERRUPT_THREAD
        || (signal==SIG_INTERRUPT_THREAD)
 #endif
index 8c40497..d2a27eb 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.10.3"
+"1.0.10.4"