From 092f7dff3f7a0fafcc02ecb4a67e673f90aa7354 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 24 Jul 2012 10:34:15 +0400 Subject: [PATCH] Fix GC_dirty_init by avoiding GC_get_suspend_signal if no threads support (fix commit '05daaee') * os_dep.c (GC_dirty_init): Pass SIG_SUSPEND instead of GC_get_suspend_signal() to sigaddset() if no THREADS (or if GC_OPENBSD_THREADS, or GC_WIN32_THREADS or NACL). * pthread_support.c (pthread_sigmask): Assert GC_get_suspend_signal() does not return -1 (only if not GC_NO_PTHREAD_SIGMASK). --- os_dep.c | 7 ++++++- pthread_support.c | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/os_dep.c b/os_dep.c index 84ea1ca..a178c2e 100644 --- a/os_dep.c +++ b/os_dep.c @@ -3317,7 +3317,12 @@ GC_INNER void GC_remove_protection(struct hblk *h, word nblocks, /* Arrange to postpone the signal while we are in a write fault */ /* handler. This effectively makes the handler atomic w.r.t. */ /* stopping the world for GC. */ - (void)sigaddset(&act.sa_mask, GC_get_suspend_signal()); +# if defined(THREADS) && !defined(GC_OPENBSD_THREADS) \ + && !defined(GC_WIN32_THREADS) && !defined(NACL) + (void)sigaddset(&act.sa_mask, GC_get_suspend_signal()); +# else + (void)sigaddset(&act.sa_mask, SIG_SUSPEND); +# endif # endif # endif if (GC_print_stats == VERBOSE) diff --git a/pthread_support.c b/pthread_support.c index 4dad56f..acd4b66 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -1140,11 +1140,14 @@ GC_INNER void GC_init_parallel(void) sigset_t *oset) { sigset_t fudged_set; + int sig_suspend; INIT_REAL_SYMS(); if (set != NULL && (how == SIG_BLOCK || how == SIG_SETMASK)) { fudged_set = *set; - sigdelset(&fudged_set, GC_get_suspend_signal()); + sig_suspend = GC_get_suspend_signal(); + GC_ASSERT(sig_suspend >= 0); + sigdelset(&fudged_set, sig_suspend); set = &fudged_set; } return(REAL_FUNC(pthread_sigmask)(how, set, oset)); -- 2.7.4