Workaround a bug in winpthreads causing parallel marks deadlock (MinGW)
authorAdrian Pop <adrian.pop@liu.se>
Fri, 10 Jun 2016 17:39:18 +0000 (20:39 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 10 Jun 2016 17:39:18 +0000 (20:39 +0300)
The solution is to use Win32 threads for parallel markers while using
winpthreads to provide GC-aware pthread_create/join/detach and fork.

See details in GitHub issue #81 and issue #119.

* win32_threads.c (GC_PTHREADS_PARAMARK): Do not define if
GC_PTHREADS, PARALLEL_MARK and __MINGW32__ (to workaround a deadlock
in do_sema_b_wait() of winpthreads).

win32_threads.c

index 91d6da2..e1c004c 100644 (file)
@@ -1686,7 +1686,12 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
 
 # if defined(GC_PTHREADS) && !defined(GC_PTHREADS_PARAMARK)
     /* Use pthread-based parallel mark implementation.    */
-#   define GC_PTHREADS_PARAMARK
+
+    /* Workaround a deadlock in winpthreads-3.0b internals (observed    */
+    /* with MinGW 32/64).                                               */
+#   if !defined(__MINGW32__)
+#     define GC_PTHREADS_PARAMARK
+#   endif
 # endif
 
 # if !defined(GC_PTHREADS_PARAMARK)