changeset 12310:f6c1979096f3

8169423: Infinite loop in G1's ConcurrentMarkThread Summary: Also terminate loop if has_aborted flag is set. Reviewed-by: tschatzl, sjohanss
author kbarrett
date Tue, 15 Nov 2016 19:39:51 -0500
parents 7c695e0b87d0
children 1d8d01c86279
files src/share/vm/gc/g1/concurrentMarkThread.cpp
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc/g1/concurrentMarkThread.cpp	Tue Nov 15 08:34:56 2016 -0500
+++ b/src/share/vm/gc/g1/concurrentMarkThread.cpp	Tue Nov 15 19:39:51 2016 -0500
@@ -156,9 +156,7 @@
       jlong mark_start = os::elapsed_counter();
       log_info(gc, marking)("Concurrent Mark (%.3fs)", TimeHelper::counter_to_seconds(mark_start));
 
-      int iter = 0;
-      do {
-        iter++;
+      for (uint iter = 1; true; ++iter) {
         if (!cm()->has_aborted()) {
           G1ConcPhaseTimer t(_cm, "Concurrent Mark From Roots");
           _cm->mark_from_roots();
@@ -178,11 +176,14 @@
           VM_CGC_Operation op(&final_cl, "Pause Remark");
           VMThread::execute(&op);
         }
-        if (cm()->restart_for_overflow()) {
-          log_debug(gc, marking)("Restarting Concurrent Marking because of Mark Stack Overflow in Remark (Iteration #%d).", iter);
-          log_info(gc, marking)("Concurrent Mark Restart due to overflow");
+
+        if (!cm()->restart_for_overflow() || cm()->has_aborted()) {
+          break;
         }
-      } while (cm()->restart_for_overflow());
+
+        log_info(gc, marking)("Concurrent Mark Restart due to overflow"
+                              " (iteration #%u", iter);
+      }
 
       if (!cm()->has_aborted()) {
         G1ConcPhaseTimer t(_cm, "Concurrent Create Live Data");