Add assertion for suspend_ack_sem in start_world
authorIvan Maidanski <ivmai@mail.ru>
Thu, 28 Dec 2017 08:04:40 +0000 (11:04 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 28 Dec 2017 08:05:50 +0000 (11:05 +0300)
This is to check that sem_post() is not called twice for a thread
(to stop) in GC_suspend_handler.

* pthread_stop_world.c [!NACL && GC_ASSERTIONS && !GC_OPENBSD_UTHREADS]
(GC_start_world): Add assertion that GC_suspend_ack_sem has zero value.

pthread_stop_world.c

index 781c23b..6e9f406 100644 (file)
@@ -1099,6 +1099,13 @@ GC_INNER void GC_start_world(void)
         }
       }
 #   endif
+#   if defined(GC_ASSERTIONS) && !defined(GC_OPENBSD_UTHREADS)
+      {
+        int ack_count;
+        sem_getvalue(&GC_suspend_ack_sem, &ack_count);
+        GC_ASSERT(0 == ack_count);
+      }
+#   endif
 #   ifdef DEBUG_THREADS
       GC_log_printf("World started\n");
 #   endif