From 21d361e944a599e82e5ed93aa81ad485b4601843 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Tue, 28 Nov 2023 20:55:27 +0000 Subject: [PATCH] 8320525: G1: G1UpdateRemSetTrackingBeforeRebuild::distribute_marked_bytes accesses partially unloaded klass Reviewed-by: ayang, iwalulya --- src/hotspot/share/gc/g1/g1ConcurrentMark.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp index d41fd381e23..a9bafa44664 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp @@ -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) {