From: Ivan Maidanski Date: Mon, 18 Sep 2017 21:34:15 +0000 (+0300) Subject: Fix missing started_thread_while_stopped call from mark_some if GCC/Clang X-Git-Tag: v7.6.2~68 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2e1fe9da3baa921bc5fe62f1922f055574165a58;p=gc 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__. --- diff --git a/mark.c b/mark.c index a77f9662..5f46a801 100644 --- a/mark.c +++ b/mark.c @@ -462,9 +462,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? */ @@ -498,7 +498,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 */ @@ -541,6 +541,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 5a41a796..cb6c1112 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. */