]> granicus.if.org Git - gc/commitdiff
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>
Fri, 23 Nov 2018 22:21:02 +0000 (01:21 +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 1d4df98076816a4c0eabf307d13e1dba76cd5703..32f0b8573746583d4ca7ef135d34cad0baa643f9 100644 (file)
@@ -1936,7 +1936,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 8e0845ccbb5d4ecd55e919c57e17f0bf5ce3f55f..a2574e7356b7062024d828b235769e5d3a9657aa 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 225d8e0dcd2c4ac6e84bcc6ad980fbc8ad939165..4c492ca8db05031fffffb3cf91a499963834815a 100644 (file)
@@ -365,7 +365,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,