8217794: Missing termination check results violation of termination invariant
authorzgu
Tue, 29 Jan 2019 12:12:27 -0500
changeset 53553 d68e38b01cf0
parent 53552 0f5fd67d0886
child 53554 005bcf879e09
8217794: Missing termination check results violation of termination invariant Reviewed-by: tschatzl, shade
src/hotspot/share/gc/shared/owstTaskTerminator.cpp
--- a/src/hotspot/share/gc/shared/owstTaskTerminator.cpp	Tue Jan 29 11:56:51 2019 -0500
+++ b/src/hotspot/share/gc/shared/owstTaskTerminator.cpp	Tue Jan 29 12:12:27 2019 -0500
@@ -65,6 +65,13 @@
         return true;
       } else {
         _blocker->lock_without_safepoint_check();
+        // There is possibility that termination is reached between dropping the lock
+        // before returning from do_spin_master_work() and acquiring lock above.
+        if (_offered_termination == _n_threads) {
+          _blocker->unlock();
+          assert(!peek_in_queue_set(), "Precondition");
+          return true;
+        }
       }
     } else {
       _blocker->wait(true, WorkStealingSleepMillis);