7040450: G1: assert((_g1->evacuation_failed()) || (!_g1->obj_in_cs(obj))) failed: shouldn't still be in ...
Summary: There is a race in the evac failure handling code that causes the condition the assert checks not to be true. The fix is to replace the too-strong assert with a more targeted one.
Reviewed-by: johnc, ysr, jcoomes
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Wed May 04 15:08:44 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Thu May 05 09:15:52 2011 -0400
@@ -3975,6 +3975,9 @@
oop
G1CollectedHeap::handle_evacuation_failure_par(OopsInHeapRegionClosure* cl,
oop old) {
+ assert(obj_in_cs(old),
+ err_msg("obj: "PTR_FORMAT" should still be in the CSet",
+ (HeapWord*) old));
markOop m = old->mark();
oop forward_ptr = old->forward_to_atomic(old);
if (forward_ptr == NULL) {
@@ -3997,7 +4000,13 @@
}
return old;
} else {
- // Someone else had a place to copy it.
+ // Forward-to-self failed. Either someone else managed to allocate
+ // space for this object (old != forward_ptr) or they beat us in
+ // self-forwarding it (old == forward_ptr).
+ assert(old == forward_ptr || !obj_in_cs(forward_ptr),
+ err_msg("obj: "PTR_FORMAT" forwarded to: "PTR_FORMAT" "
+ "should not be in the CSet",
+ (HeapWord*) old, (HeapWord*) forward_ptr));
return forward_ptr;
}
}
@@ -4308,11 +4317,10 @@
T heap_oop = oopDesc::load_heap_oop(p);
if (!oopDesc::is_null(heap_oop)) {
oop obj = oopDesc::decode_heap_oop(heap_oop);
- assert((_g1->evacuation_failed()) || (!_g1->obj_in_cs(obj)),
- "shouldn't still be in the CSet if evacuation didn't fail.");
HeapWord* addr = (HeapWord*)obj;
- if (_g1->is_in_g1_reserved(addr))
+ if (_g1->is_in_g1_reserved(addr)) {
_cm->grayRoot(oop(addr));
+ }
}
}