src/share/vm/gc_implementation/g1/concurrentMark.cpp

Print this page
rev 6927 : 8054808: Bitmap verification sometimes fails after Full GC aborts concurrent mark.
Summary: The verification code that checked whether no bitmap mark had been found re-read HeapRegion::end() after the check on the bitmap. Concurrent humongous object allocation could have changed HeapRegion::end() in the meantime. Fix this by using the actual end of the region instead of HeapRegion::end() for comparison.
Reviewed-by:

@@ -886,11 +886,15 @@
  public:
   CheckBitmapClearHRClosure(CMBitMap* bitmap) : _bitmap(bitmap) {
   }
 
   virtual bool doHeapRegion(HeapRegion* r) {
-    return _bitmap->getNextMarkedWordAddress(r->bottom(), r->end()) != r->end();
+    HeapWord* end = r->bottom() + HeapRegion::GrainWords;
+    // There cannot be a race when comparing to "end" after the call even if the
+    // compiler duplicates the calculation of "end" because r->bottom() is always
+    // constant.
+    return _bitmap->getNextMarkedWordAddress(r->bottom(), end) != end;
   }
 };
 
 bool ConcurrentMark::nextMarkBitmapIsClear() {
   CheckBitmapClearHRClosure cl(_nextMarkBitMap);