JDK-8217794 : Missing termination check results violation of termination invariant
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 8-shenandoah,11-shenandoah,13
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2019-01-25
  • Updated: 2019-08-08
  • Resolved: 2019-01-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 12 JDK 13
12.0.2Fixed 13 b06Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
diff --git a/src/hotspot/share/gc/shared/owstTaskTerminator.cpp b/src/hotspot/share/gc/shared/owstTaskTerminator.cpp
--- a/src/hotspot/share/gc/shared/owstTaskTerminator.cpp
+++ b/src/hotspot/share/gc/shared/owstTaskTerminator.cpp

@@ -59,21 +61,31 @@
 
       if (do_spin_master_work(terminator)) {
         assert(_offered_termination == _n_threads, "termination condition");
+        assert(!peek_in_queue_set(), "Precondition");
         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() and acquiring lock above.
+        if (_offered_termination == _n_threads) {
+          _blocker->unlock();
+          assert(!peek_in_queue_set(), "Precondition");
+          return true;
+        }

Comments
Fix Request: I would like to backport this patch to JDK12u. This patch, together with JDK-8215047 (requested), improves task termination latency, by eliminating false positive termination check.
28-02-2019

Looks like this indeed a bug after this was separated from JDK-8215047. After re-acquiring lock when it returns from do_spin_master_work(), it blindly reduces _offered_termination counter. If termination is reached just before it acquires the blocker lock, then it violates the invariant enforced by JDK-8215047, that is, if terminator ever reaches termination state, it should stay in termination state.
29-01-2019