From 42ab0c5b87f834c69842713c60587a76f953411f Mon Sep 17 00:00:00 2001 From: NIIMI Satoshi Date: Wed, 26 Sep 2007 11:42:32 +0000 Subject: [PATCH] 1.0.10.4: Use variable for SIG_MEMORY_FAULT on FreeBSD 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 | 24 +++++++++++------------- src/runtime/bsd-os.h | 7 +++++-- src/runtime/interrupt.c | 3 --- version.lisp-expr | 2 +- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/runtime/bsd-os.c b/src/runtime/bsd-os.c index b932fd61f..e764c3ee6 100644 --- a/src/runtime/bsd-os.c +++ b/src/runtime/bsd-os.c @@ -242,13 +242,6 @@ os_install_interrupt_handlers(void) (__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 @@ -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); -#ifdef SIG_MEMORY_FAULT2 - undoably_install_low_level_interrupt_handler(SIG_MEMORY_FAULT2, - sigsegv_handler); -#endif } #endif /* defined GENCGC */ @@ -375,8 +364,19 @@ _socket(int domain, int type, int protocol) #endif /* __NetBSD__ */ #ifdef __FreeBSD__ +extern int getosreldate(void); + +int sig_memory_fault; + 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 @@ -441,8 +441,6 @@ futex_wake(int *lock_word, int n) #define KERN_PROC_PATHNAME 12 #endif -extern int getosreldate(void); - char * os_get_runtime_executable_path() { diff --git a/src/runtime/bsd-os.h b/src/runtime/bsd-os.h index 232451474..f1669d6cc 100644 --- a/src/runtime/bsd-os.h +++ b/src/runtime/bsd-os.h @@ -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 -#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 @@ -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 */ -#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) diff --git a/src/runtime/interrupt.c b/src/runtime/interrupt.c index d99514259..c702e58a4 100644 --- a/src/runtime/interrupt.c +++ b/src/runtime/interrupt.c @@ -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) -#ifdef SIG_MEMORY_FAULT2 - || (signal==SIG_MEMORY_FAULT2) -#endif #ifdef SIG_INTERRUPT_THREAD || (signal==SIG_INTERRUPT_THREAD) #endif diff --git a/version.lisp-expr b/version.lisp-expr index 8c4049783..d2a27eb75 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -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".) -"1.0.10.3" +"1.0.10.4" -- 2.11.4.GIT