From f9bb3676e3d2c5fe0ae505d3bcbf434f7acb524f Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Fri, 5 Aug 2022 16:20:27 +0000 Subject: [PATCH] 8291653: G1 refinement incorrectly expects always-valid HeapRegion out of the Hot Card Cache Reviewed-by: kbarrett, ayang --- src/hotspot/share/gc/g1/g1RemSet.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1RemSet.cpp b/src/hotspot/share/gc/g1/g1RemSet.cpp index 14a776df376..cff382c5b53 100644 --- a/src/hotspot/share/gc/g1/g1RemSet.cpp +++ b/src/hotspot/share/gc/g1/g1RemSet.cpp @@ -1668,12 +1668,13 @@ bool G1RemSet::clean_card_before_refine(CardValue** const card_ptr_addr) { } else if (card_ptr != orig_card_ptr) { // Original card was inserted and an old card was evicted. start = _ct->addr_for(card_ptr); - r = _g1h->heap_region_containing(start); + r = _g1h->heap_region_containing_or_null(start); // Check whether the region formerly in the cache should be // ignored, as discussed earlier for the original card. The - // region could have been freed while in the cache. - if (!r->is_old_or_humongous_or_archive()) { + // region could have been freed (or even uncommitted) while + // in the cache. + if (r == nullptr || !r->is_old_or_humongous_or_archive()) { return false; } *card_ptr_addr = card_ptr;