diff src/share/vm/gc_implementation/g1/concurrentMark.cpp @ 20386:edb5f3b38aab

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: brutisso, jmasa
author tschatzl
date Thu, 28 Aug 2014 17:05:41 +0200
parents 9337d0e7ea4f
children e5668dcf12e9
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Wed Sep 03 08:44:47 2014 +0000
+++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Thu Aug 28 17:05:41 2014 +0200
@@ -887,7 +887,16 @@
   }
 
   virtual bool doHeapRegion(HeapRegion* r) {
-    return _bitmap->getNextMarkedWordAddress(r->bottom(), r->end()) != r->end();
+    // This closure can be called concurrently to the mutator, so we must make sure
+    // that the result of the getNextMarkedWordAddress() call is compared to the
+    // value passed to it as limit to detect any found bits.
+    // We can use the region's orig_end() for the limit and the comparison value
+    // as it always contains the "real" end of the region that never changes and
+    // has no side effects.
+    // Due to the latter, there can also be no problem with the compiler generating
+    // reloads of the orig_end() call.
+    HeapWord* end = r->orig_end();
+    return _bitmap->getNextMarkedWordAddress(r->bottom(), end) != end;
   }
 };