Fix 'collecting from unknown thread' abort in leak-finding mode for Win32
authorIvan Maidanski <ivmai@mail.ru>
Thu, 22 Nov 2018 23:22:41 +0000 (02:22 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 22 Nov 2018 23:22:41 +0000 (02:22 +0300)
(fix of commit 8e6460052)

* include/private/gc_priv.h [THREADS] (GC_in_thread_creation): Declare
not only for pthreads.
* misc.c [!DONT_USE_ATEXIT && THREADS] (GC_exit_check): Set
GC_in_thread_creation to true before calling GC_gcollect for windows
threads as well.
* win32_threads.c (GC_in_thread_creation): Change STATIC to GC_INNER.

include/private/gc_priv.h
misc.c
win32_threads.c

index 949f1f6..1eb3aa6 100644 (file)
@@ -1930,7 +1930,7 @@ GC_INNER GC_bool GC_try_to_collect_inner(GC_stop_func f);
 #define GC_gcollect_inner() \
                 (void)GC_try_to_collect_inner(GC_never_stop_func)
 
-#if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS)
+#ifdef THREADS
   GC_EXTERN GC_bool GC_in_thread_creation;
         /* We may currently be in thread creation or destruction.       */
         /* Only set to TRUE while allocation lock is held.              */
diff --git a/misc.c b/misc.c
index 7e0bef7..e56c3de 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -764,7 +764,7 @@ GC_API int GC_CALL GC_is_init_called(void)
   STATIC void GC_exit_check(void)
   {
     if (GC_find_leak && !skip_gc_atexit) {
-#     if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS)
+#     ifdef THREADS
         GC_in_thread_creation = TRUE; /* OK to collect from unknown thread. */
         GC_gcollect();
         GC_in_thread_creation = FALSE;
index e2fc9e1..a9053a7 100644 (file)
@@ -370,7 +370,7 @@ STATIC GC_thread GC_new_thread(DWORD id)
   return(result);
 }
 
-STATIC GC_bool GC_in_thread_creation = FALSE;
+GC_INNER GC_bool GC_in_thread_creation = FALSE;
                                 /* Protected by allocation lock. */
 
 GC_INLINE void GC_record_stack_base(GC_vthread me,