Skip to content

Commit 3a21a27

Browse files
William KemperPaul Hohensee
authored andcommitted
8360288: Shenandoah crash at size_given_klass in op_degenerated
Reviewed-by: phh Backport-of: 3b44d7bfa4d78e3ec715fce1863e052852f33180
1 parent 6eb8033 commit 3a21a27

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,26 +1039,23 @@ void ShenandoahHeap::print_heap_regions_on(outputStream* st) const {
10391039
}
10401040
}
10411041

1042-
void ShenandoahHeap::trash_humongous_region_at(ShenandoahHeapRegion* start) {
1042+
size_t ShenandoahHeap::trash_humongous_region_at(ShenandoahHeapRegion* start) const {
10431043
assert(start->is_humongous_start(), "reclaim regions starting with the first one");
1044-
1045-
oop humongous_obj = cast_to_oop(start->bottom());
1046-
size_t size = humongous_obj->size();
1047-
size_t required_regions = ShenandoahHeapRegion::required_regions(size * HeapWordSize);
1048-
size_t index = start->index() + required_regions - 1;
1049-
10501044
assert(!start->has_live(), "liveness must be zero");
10511045

1052-
for(size_t i = 0; i < required_regions; i++) {
1053-
// Reclaim from tail. Otherwise, assertion fails when printing region to trace log,
1054-
// as it expects that every region belongs to a humongous region starting with a humongous start region.
1055-
ShenandoahHeapRegion* region = get_region(index --);
1056-
1057-
assert(region->is_humongous(), "expect correct humongous start or continuation");
1046+
// Do not try to get the size of this humongous object. STW collections will
1047+
// have already unloaded classes, so an unmarked object may have a bad klass pointer.
1048+
ShenandoahHeapRegion* region = start;
1049+
size_t index = region->index();
1050+
do {
1051+
assert(region->is_humongous(), "Expect correct humongous start or continuation");
10581052
assert(!region->is_cset(), "Humongous region should not be in collection set");
1059-
10601053
region->make_trash_immediate();
1061-
}
1054+
region = get_region(++index);
1055+
} while (region != nullptr && region->is_humongous_continuation());
1056+
1057+
// Return number of regions trashed
1058+
return index - start->index();
10621059
}
10631060

10641061
class ShenandoahCheckCleanGCLABClosure : public ThreadClosure {

src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ class ShenandoahHeap : public CollectedHeap {
651651
static inline void atomic_clear_oop(narrowOop* addr, oop compare);
652652
static inline void atomic_clear_oop(narrowOop* addr, narrowOop compare);
653653

654-
void trash_humongous_region_at(ShenandoahHeapRegion *r);
654+
size_t trash_humongous_region_at(ShenandoahHeapRegion *r) const;
655655

656656
private:
657657
void trash_cset_regions();

0 commit comments

Comments
 (0)