Skip to content

Commit 3b44d7b

Browse files
author
William Kemper
committed
8360288: Shenandoah crash at size_given_klass in op_degenerated
Reviewed-by: shade
1 parent 8193856 commit 3b44d7b

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

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

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,27 +1452,23 @@ void ShenandoahHeap::print_heap_regions_on(outputStream* st) const {
14521452
}
14531453
}
14541454

1455-
size_t ShenandoahHeap::trash_humongous_region_at(ShenandoahHeapRegion* start) {
1455+
size_t ShenandoahHeap::trash_humongous_region_at(ShenandoahHeapRegion* start) const {
14561456
assert(start->is_humongous_start(), "reclaim regions starting with the first one");
1457-
1458-
oop humongous_obj = cast_to_oop(start->bottom());
1459-
size_t size = humongous_obj->size();
1460-
size_t required_regions = ShenandoahHeapRegion::required_regions(size * HeapWordSize);
1461-
size_t index = start->index() + required_regions - 1;
1462-
14631457
assert(!start->has_live(), "liveness must be zero");
14641458

1465-
for(size_t i = 0; i < required_regions; i++) {
1466-
// Reclaim from tail. Otherwise, assertion fails when printing region to trace log,
1467-
// as it expects that every region belongs to a humongous region starting with a humongous start region.
1468-
ShenandoahHeapRegion* region = get_region(index --);
1469-
1470-
assert(region->is_humongous(), "expect correct humongous start or continuation");
1459+
// Do not try to get the size of this humongous object. STW collections will
1460+
// have already unloaded classes, so an unmarked object may have a bad klass pointer.
1461+
ShenandoahHeapRegion* region = start;
1462+
size_t index = region->index();
1463+
do {
1464+
assert(region->is_humongous(), "Expect correct humongous start or continuation");
14711465
assert(!region->is_cset(), "Humongous region should not be in collection set");
1472-
14731466
region->make_trash_immediate();
1474-
}
1475-
return required_regions;
1467+
region = get_region(++index);
1468+
} while (region != nullptr && region->is_humongous_continuation());
1469+
1470+
// Return number of regions trashed
1471+
return index - start->index();
14761472
}
14771473

14781474
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
@@ -829,7 +829,7 @@ class ShenandoahHeap : public CollectedHeap {
829829
static inline void atomic_clear_oop(narrowOop* addr, oop compare);
830830
static inline void atomic_clear_oop(narrowOop* addr, narrowOop compare);
831831

832-
size_t trash_humongous_region_at(ShenandoahHeapRegion *r);
832+
size_t trash_humongous_region_at(ShenandoahHeapRegion *r) const;
833833

834834
static inline void increase_object_age(oop obj, uint additional_age);
835835

0 commit comments

Comments
 (0)