From 328e8d6989f7cdf7fce1aedb398b61dd5b56d755 Mon Sep 17 00:00:00 2001 From: Xiaolong Peng Date: Wed, 3 Jun 2026 09:24:56 -0700 Subject: [PATCH] fix: Assert retained region stays a partition member to catch staleness --- .../share/gc/shenandoah/shenandoahPartitionAllocator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPartitionAllocator.cpp b/src/hotspot/share/gc/shenandoah/shenandoahPartitionAllocator.cpp index ad490c0b62b..855da113407 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahPartitionAllocator.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahPartitionAllocator.cpp @@ -55,8 +55,9 @@ HeapWord* ShenandoahPartitionAllocator::allocate(ShenandoahAllocReque if (_retained_region != nullptr) { constexpr ShenandoahAffiliation affiliation = (PARTITION == ShenandoahFreeSetPartitionId::OldCollector) ? OLD_GENERATION : YOUNG_GENERATION; - assert(!_retained_region->is_trash() && _retained_region->affiliation() == affiliation, - "Retained region %zu must stay affiliated to this partition until the free set is rebuilt", + assert(!_retained_region->is_trash() && _retained_region->affiliation() == affiliation && + _free_set->membership(_retained_region->index()) == PARTITION, + "Retained region %zu must remain a non-trash member of this partition until the free set is rebuilt", _retained_region->index()); HeapWord* result = nullptr; size_t ac_words = _retained_region->free() >> LogHeapWordSize;