From: Ivan Maidanski Date: Tue, 21 Jun 2016 20:38:23 +0000 (+0300) Subject: Fix assertion violation in GC_wait_builder called from start_mark_threads X-Git-Tag: gc7_6_0~27 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d02ea9707b8d9bb1fd0b3d908a107198658ca2ad;p=gc Fix assertion violation in GC_wait_builder called from start_mark_threads (fix commit 0ca6d3f) * include/private/gc_priv.h [PARALLEL_MARK] (GC_start_mark_threads_inner): Declare even if no CAN_HANDLE_FORK. * misc.c [THREADS] (GC_start_mark_threads): Define also for the case of PARALLEL_MARK and CAN_HANDLE_FORK - call GC_start_mark_threads_inner surrounded with DISABLE/RESTORE_CANCEL. * pthread_support.c [PARALLEL_MARK] (GC_start_mark_threads_inner): Always define as GC_INNER. * win32_threads.c [GC_PTHREADS_PARAMARK] (GC_start_mark_threads_inner): Likewise. --- diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 8318ca41..439c1293 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -2401,11 +2401,7 @@ GC_INNER ptr_t GC_store_debug_info(ptr_t p, word sz, const char *str, /* was already done, or there was nothing to do for */ /* some other reason. */ -# ifdef CAN_HANDLE_FORK -# define GC_start_mark_threads_inner GC_start_mark_threads -# else - GC_INNER void GC_start_mark_threads_inner(void); -# endif + GC_INNER void GC_start_mark_threads_inner(void); #endif /* PARALLEL_MARK */ #if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS) && !defined(NACL) \ diff --git a/misc.c b/misc.c index 680d69ec..e68287fc 100644 --- a/misc.c +++ b/misc.c @@ -1352,11 +1352,19 @@ GC_API void GC_CALL GC_enable_incremental(void) GC_init(); } -#if defined(THREADS) && (!defined(PARALLEL_MARK) || !defined(CAN_HANDLE_FORK)) +#if defined(THREADS) GC_API void GC_CALL GC_start_mark_threads(void) { - /* No action since parallel markers are disabled (or no POSIX fork). */ - GC_ASSERT(I_DONT_HOLD_LOCK()); +# if defined(PARALLEL_MARK) && defined(CAN_HANDLE_FORK) + IF_CANCEL(int cancel_state;) + + DISABLE_CANCEL(cancel_state); + GC_start_mark_threads_inner(); + RESTORE_CANCEL(cancel_state); +# else + /* No action since parallel markers are disabled (or no POSIX fork). */ + GC_ASSERT(I_DONT_HOLD_LOCK()); +# endif } #endif diff --git a/pthread_support.c b/pthread_support.c index c9fb99f3..fe89790a 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -385,12 +385,11 @@ STATIC pthread_t GC_mark_threads[MAX_MARKERS]; #ifdef CAN_HANDLE_FORK static int available_markers_m1 = 0; - GC_API void GC_CALL #else # define available_markers_m1 GC_markers_m1 - GC_INNER void #endif - GC_start_mark_threads_inner(void) + +GC_INNER void GC_start_mark_threads_inner(void) { int i; pthread_attr_t attr; diff --git a/win32_threads.c b/win32_threads.c index e1c004c5..c4f7e928 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -1769,11 +1769,9 @@ GC_INNER void GC_get_next_stack(char *start, char *limit, /* for thread stack that is assumed to be large enough. */ # ifdef CAN_HANDLE_FORK static int available_markers_m1 = 0; - GC_API void GC_CALL -# else - GC_INNER void # endif - GC_start_mark_threads_inner(void) + + GC_INNER void GC_start_mark_threads_inner(void) { int i; pthread_attr_t attr;