Prevent POSIX fork if mprotect_thread is started (Darwin)
authorIvan Maidanski <ivmai@mail.ru>
Thu, 22 Nov 2012 04:39:20 +0000 (08:39 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 22 Nov 2012 09:43:09 +0000 (13:43 +0400)
* pthread_support.c (GC_atfork_prepare): Abort if GC_dirty_maintained
is set for Darwin (only if MPROTECT_VDB) since graceful suspend/resume
of mprotect_thread is unsupported at present.

pthread_support.c

index f270b59..c65ecfa 100644 (file)
@@ -996,6 +996,12 @@ static void fork_child_proc(void)
   /* Routines for fork handling by client (no-op if pthread_atfork works). */
   GC_API void GC_CALL GC_atfork_prepare(void)
   {
+#   if defined(GC_DARWIN_THREADS) && defined(MPROTECT_VDB)
+      if (GC_dirty_maintained) {
+        GC_ASSERT(0 == GC_handle_fork);
+        ABORT("Unable to fork while mprotect_thread is running");
+      }
+#   endif
     if (GC_handle_fork <= 0)
       fork_prepare_proc();
   }