8320525: G1: G1UpdateRemSetTrackingBeforeRebuild::distribute_marked_bytes accesses partially unloaded klass

Reviewed-by: ayang, iwalulya
This commit is contained in:
Thomas Schatzl 2023-11-28 20:55:27 +00:00
parent dc256fbc64
commit 21d361e944

View File

@ -1131,13 +1131,10 @@ class G1UpdateRemSetTrackingBeforeRebuildTask : public WorkerTask {
// Distribute the given marked bytes across the humongous object starting
// with hr and note end of marking for these regions.
void distribute_marked_bytes(HeapRegion* hr, size_t marked_bytes) {
size_t const obj_size_in_words = cast_to_oop(hr->bottom())->size();
// "Distributing" zero words means that we only note end of marking for these
// regions.
assert(marked_bytes == 0 || obj_size_in_words * HeapWordSize == marked_bytes,
// Dead humongous objects (marked_bytes == 0) may have already been unloaded.
assert(marked_bytes == 0 || cast_to_oop(hr->bottom())->size() * HeapWordSize == marked_bytes,
"Marked bytes should either be 0 or the same as humongous object (%zu) but is %zu",
obj_size_in_words * HeapWordSize, marked_bytes);
cast_to_oop(hr->bottom())->size() * HeapWordSize, marked_bytes);
auto distribute_bytes = [&] (HeapRegion* r) {
size_t const bytes_to_add = MIN2(HeapRegion::GrainBytes, marked_bytes);
@ -1148,10 +1145,6 @@ class G1UpdateRemSetTrackingBeforeRebuildTask : public WorkerTask {
marked_bytes -= bytes_to_add;
};
_g1h->humongous_obj_regions_iterate(hr, distribute_bytes);
assert(marked_bytes == 0,
"%zu bytes left after distributing space across %zu regions",
marked_bytes, G1CollectedHeap::humongous_obj_size_in_regions(obj_size_in_words));
}
void update_marked_bytes(HeapRegion* hr) {