From a96167c44596bf4e549b514dd3fd8880081510da Mon Sep 17 00:00:00 2001 From: Gabor Melis Date: Fri, 20 Mar 2009 11:15:17 +0000 Subject: [PATCH] 1.0.26.10: darwin interrupt fixes Work around raise(signal) apparently not raising the signal under some circumstances. See sbcl-devel thread "Hang in tests on Intel MacOS 10.5.6" starting on 2009-03-14. Also, block all blockables when in install_handler, having just one of the signals blocked breaks invariants (not really darwin specific). Replace abort() after the call mach_msg_server() with more a informative lose(). It's actually returns after attaching and detaching gdb. --- src/runtime/interrupt.c | 7 +++---- src/runtime/thread.c | 11 +++++++++++ src/runtime/x86-64-darwin-os.c | 2 +- src/runtime/x86-darwin-os.c | 2 +- version.lisp-expr | 2 +- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/runtime/interrupt.c b/src/runtime/interrupt.c index dc210e9..305f75f 100644 --- a/src/runtime/interrupt.c +++ b/src/runtime/interrupt.c @@ -406,7 +406,8 @@ check_interrupt_context_or_lose(os_context_t *context) lose("gc_blocked_deferrables and interrupt pending\n."); if (data->gc_blocked_deferrables) check_deferrables_blocked_in_sigset_or_lose(sigset); - if (interrupt_pending || interrupt_deferred_p) + if (interrupt_pending || interrupt_deferred_p || + data->gc_blocked_deferrables) check_deferrables_blocked_in_sigset_or_lose(sigset); else { check_deferrables_unblocked_in_sigset_or_lose(sigset); @@ -1604,9 +1605,7 @@ install_handler(int signal, void handler(int, siginfo_t*, os_context_t*)) FSHOW((stderr, "/entering POSIX install_handler(%d, ..)\n", signal)); - sigemptyset(&new); - sigaddset(&new, signal); - thread_sigmask(SIG_BLOCK, &new, &old); + thread_sigmask(SIG_BLOCK, &blockable_sigset, &old); FSHOW((stderr, "/interrupt_low_level_handlers[signal]=%x\n", (unsigned int)interrupt_low_level_handlers[signal])); diff --git a/src/runtime/thread.c b/src/runtime/thread.c index f8cb1ca..1da1108 100644 --- a/src/runtime/thread.c +++ b/src/runtime/thread.c @@ -721,7 +721,18 @@ kill_safely(os_thread_t os_thread, int signal) int status; if (os_thread != 0) lose("kill_safely: who do you want to kill? %d?\n", os_thread); + /* Dubious (as in don't know why it works) workaround for the + * signal sometimes not being generated on darwin. */ +#ifdef LISP_FEATURE_DARWIN + { + sigset_t oldset; + sigprocmask(SIG_BLOCK, &deferrable_sigset, &oldset); + status = raise(signal); + sigprocmask(SIG_SETMASK,&oldset,0); + } +#else status = raise(signal); +#endif if (status == 0) { return 0; } else { diff --git a/src/runtime/x86-64-darwin-os.c b/src/runtime/x86-64-darwin-os.c index 35ac2f9..046a125 100644 --- a/src/runtime/x86-64-darwin-os.c +++ b/src/runtime/x86-64-darwin-os.c @@ -579,7 +579,7 @@ mach_exception_handler(void *port) /* mach_msg_server should never return, but it should dispatch mach * exceptions to our catch_exception_raise function */ - abort(); + lose("mach_msg_server returned"); } /* Sets up the thread that will listen for mach exceptions. note that diff --git a/src/runtime/x86-darwin-os.c b/src/runtime/x86-darwin-os.c index 1cc837c..c657565 100644 --- a/src/runtime/x86-darwin-os.c +++ b/src/runtime/x86-darwin-os.c @@ -514,7 +514,7 @@ mach_exception_handler(void *port) /* mach_msg_server should never return, but it should dispatch mach * exceptions to our catch_exception_raise function */ - abort(); + lose("mach_msg_server returned"); } #endif diff --git a/version.lisp-expr b/version.lisp-expr index e80cc75..b5cc8c4 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.26.9" +"1.0.26.10" -- 1.7.10.4