8068036: assert(is_available(index)) failed in G1 cset
authortschatzl
Mon, 22 Dec 2014 16:49:24 +0100
changeset 28215 4920c0fcdb07
parent 28213 b0bf57cd1e9d
child 28216 25cac6c2349d
8068036: assert(is_available(index)) failed in G1 cset Summary: Some verification code iterated over the heap using the region mapping array. This is not allowed. Changed to use the regular iteration method with closure. Reviewed-by: jwilhelm, brutisso
hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Fri Dec 19 09:21:06 2014 +0100
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Mon Dec 22 16:49:24 2014 +0100
@@ -5900,56 +5900,68 @@
   guarantee(!cl.failures(), "bitmap verification");
 }
 
-bool G1CollectedHeap::check_cset_fast_test() {
-  bool failures = false;
-  for (uint i = 0; i < _hrm.length(); i += 1) {
-    HeapRegion* hr = _hrm.at(i);
-    InCSetState cset_state = (InCSetState) _in_cset_fast_test.get_by_index((uint) i);
+class G1CheckCSetFastTableClosure : public HeapRegionClosure {
+ private:
+  bool _failures;
+ public:
+  G1CheckCSetFastTableClosure() : HeapRegionClosure(), _failures(false) { }
+
+  virtual bool doHeapRegion(HeapRegion* hr) {
+    uint i = hr->hrm_index();
+    InCSetState cset_state = (InCSetState) G1CollectedHeap::heap()->_in_cset_fast_test.get_by_index(i);
     if (hr->is_humongous()) {
       if (hr->in_collection_set()) {
         gclog_or_tty->print_cr("\n## humongous region %u in CSet", i);
-        failures = true;
-        break;
+        _failures = true;
+        return true;
       }
       if (cset_state.is_in_cset()) {
         gclog_or_tty->print_cr("\n## inconsistent cset state %d for humongous region %u", cset_state.value(), i);
-        failures = true;
-        break;
+        _failures = true;
+        return true;
       }
       if (hr->is_continues_humongous() && cset_state.is_humongous()) {
         gclog_or_tty->print_cr("\n## inconsistent cset state %d for continues humongous region %u", cset_state.value(), i);
-        failures = true;
-        break;
+        _failures = true;
+        return true;
       }
     } else {
       if (cset_state.is_humongous()) {
         gclog_or_tty->print_cr("\n## inconsistent cset state %d for non-humongous region %u", cset_state.value(), i);
-        failures = true;
-        break;
+        _failures = true;
+        return true;
       }
       if (hr->in_collection_set() != cset_state.is_in_cset()) {
         gclog_or_tty->print_cr("\n## in CSet %d / cset state %d inconsistency for region %u",
                                hr->in_collection_set(), cset_state.value(), i);
-        failures = true;
-        break;
+        _failures = true;
+        return true;
       }
       if (cset_state.is_in_cset()) {
         if (hr->is_young() != (cset_state.is_young())) {
           gclog_or_tty->print_cr("\n## is_young %d / cset state %d inconsistency for region %u",
                                  hr->is_young(), cset_state.value(), i);
-          failures = true;
-          break;
+          _failures = true;
+          return true;
         }
         if (hr->is_old() != (cset_state.is_old())) {
           gclog_or_tty->print_cr("\n## is_old %d / cset state %d inconsistency for region %u",
                                  hr->is_old(), cset_state.value(), i);
-          failures = true;
-          break;
+          _failures = true;
+          return true;
         }
       }
     }
-  }
-  return !failures;
+    return false;
+  }
+
+  bool failures() const { return _failures; }
+};
+
+bool G1CollectedHeap::check_cset_fast_test() {
+  G1CheckCSetFastTableClosure cl;
+  _hrm.iterate(&cl);
+  return !cl.failures();
 }
 #endif // PRODUCT
 
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Fri Dec 19 09:21:06 2014 +0100
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Mon Dec 22 16:49:24 2014 +0100
@@ -214,6 +214,9 @@
   friend class G1MarkSweep;
   friend class HeapRegionClaimer;
 
+  // Testing classes.
+  friend class G1CheckCSetFastTableClosure;
+
 private:
   // The one and only G1CollectedHeap, so static functions can find it.
   static G1CollectedHeap* _g1h;