From 0ba115c49f4d7033703d88ef0f027900bc6d5b40 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Mon, 27 Apr 2026 09:01:42 +0000 Subject: [PATCH] 8382635: G1: TAMSes overwritten by G1ConcurrentMark::fully_initialize() cause verification errors Reviewed-by: iwalulya, ayang --- src/hotspot/share/gc/g1/g1ConcurrentMark.cpp | 5 ++++- src/hotspot/share/gc/g1/g1_globals.hpp | 2 +- test/hotspot/jtreg/gc/g1/TestVerifyGCType.java | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp index d5e3b9cc69d..9952fab5e2c 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp @@ -524,7 +524,10 @@ void G1ConcurrentMark::fully_initialize() { uint max_num_regions = _g1h->max_num_regions(); ::new (_region_mark_stats) G1RegionMarkStats[max_num_regions]{}; - ::new (_top_at_mark_starts) Atomic[max_num_regions]{}; + for (uint i = 0; i < max_num_regions; i++) { + ::new (&_top_at_mark_starts[i]) Atomic(_g1h->bottom_addr_for_region(i)); + } + // Contrary to TAMS, the default value of _top_at_rebuild_starts needs to be null. ::new (_top_at_rebuild_starts) Atomic[max_num_regions]{}; reset_at_marking_complete(); diff --git a/src/hotspot/share/gc/g1/g1_globals.hpp b/src/hotspot/share/gc/g1/g1_globals.hpp index b338c11d5be..baed70b7088 100644 --- a/src/hotspot/share/gc/g1/g1_globals.hpp +++ b/src/hotspot/share/gc/g1/g1_globals.hpp @@ -316,7 +316,7 @@ product(bool, G1VerifyHeapRegionCodeRoots, false, DIAGNOSTIC, \ "Verify the code root lists attached to each heap region.") \ \ - develop(bool, G1VerifyBitmaps, false, \ + product(bool, G1VerifyBitmaps, false, DIAGNOSTIC, \ "Verifies the consistency of the marking bitmaps") \ \ product(uintx, G1PeriodicGCInterval, 0, MANAGEABLE, \ diff --git a/test/hotspot/jtreg/gc/g1/TestVerifyGCType.java b/test/hotspot/jtreg/gc/g1/TestVerifyGCType.java index 710236e1aae..fb04f54f641 100644 --- a/test/hotspot/jtreg/gc/g1/TestVerifyGCType.java +++ b/test/hotspot/jtreg/gc/g1/TestVerifyGCType.java @@ -166,6 +166,7 @@ public class TestVerifyGCType { "-Xmx16m", "-XX:ParallelGCThreads=1", "-XX:G1HeapWastePercent=1", + "-XX:+G1VerifyBitmaps", "-XX:+VerifyBeforeGC", "-XX:+VerifyAfterGC", "-XX:+VerifyDuringGC"});