Fix missing started_thread_while_stopped call from mark_some if GCC/Clang
authorIvan Maidanski <ivmai@mail.ru>
Mon, 18 Sep 2017 21:34:15 +0000 (00:34 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 18 Sep 2017 21:34:15 +0000 (00:34 +0300)
* 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
win32_threads.c

diff --git a/mark.c b/mark.c
index b79156d..e56d5f9 100644 (file)
--- 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));
index 833d6d1..a99eec1 100644 (file)
@@ -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.                          */