From b4e2df9080a21b9912269db8c74bec755e8a6223 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 19 Sep 2017 00:34:15 +0300 Subject: [PATCH] Fix missing started_thread_while_stopped call from mark_some if GCC/Clang * mark.c [WRAP_MARK_SOME && GC_WIN32_THREADS && !GC_PTHREADS] (GC_started_thread_while_stopped): Declare even if __GNUC__. * mark.c [WRAP_MARK_SOME && GC_WIN32_THREADS && (MSWIN32 || MSWINCE)] (GC_mark_some): Invoke GC_started_thread_while_stopped (unless GC_PTHREADS). * win32_threads.c [WRAP_MARK_SOME && !GC_PTHREADS] (GC_started_thread_while_stopped): Define even if __GNUC__. --- mark.c | 10 +++++++--- win32_threads.c | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/mark.c b/mark.c index b79156d5..e56d5f97 100644 --- a/mark.c +++ b/mark.c @@ -474,9 +474,9 @@ static void alloc_mark_stack(size_t); return ExceptionContinueSearch; } } -# endif /* __GNUC__ && MSWIN32 */ +# endif /* __GNUC__ && MSWIN32 */ -#if defined(GC_WIN32_THREADS) && !defined(__GNUC__) +#if defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS) GC_INNER GC_bool GC_started_thread_while_stopped(void); /* In win32_threads.c. Did we invalidate mark phase with an */ /* unexpected thread start? */ @@ -510,7 +510,7 @@ static void alloc_mark_stack(size_t); EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { goto handle_ex; } -# ifdef GC_WIN32_THREADS +# if defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS) /* With DllMain-based thread tracking, a thread may have */ /* started while we were marking. This is logically equivalent */ /* to the exception case; our results are invalid and we have */ @@ -551,6 +551,10 @@ static void alloc_mark_stack(size_t); /* and thus eliminating it. */ if (er.alt_path == 0) goto handle_ex; +# if defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS) + if (GC_started_thread_while_stopped()) + goto handle_ex; +# endif rm_handler: /* Uninstall the exception handler */ __asm__ __volatile__ ("mov %0, %%fs:0" : : "r" (er.ex_reg.prev)); diff --git a/win32_threads.c b/win32_threads.c index 833d6d15..a99eec1a 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -274,7 +274,7 @@ typedef volatile struct GC_Thread_Rep * GC_vthread; STATIC volatile AO_t GC_attached_thread = FALSE; #endif -#if !defined(__GNUC__) +#if defined(WRAP_MARK_SOME) && !defined(GC_PTHREADS) /* Return TRUE if an thread was attached since we last asked or */ /* since GC_attached_thread was explicitly reset. */ GC_INNER GC_bool GC_started_thread_while_stopped(void) @@ -296,7 +296,7 @@ typedef volatile struct GC_Thread_Rep * GC_vthread; # endif return FALSE; } -#endif /* !__GNUC__ */ +#endif /* WRAP_MARK_SOME */ /* Thread table used if GC_win32_dll_threads is set. */ /* This is a fixed size array. */ -- 2.40.0