JDK-8349688 : G1: Wrong initial optional region index when selecting candidates from retained regions
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 25
  • Priority: P2
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2025-02-09
  • Updated: 2025-02-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 25
25Unresolved
Related Reports
Causes :  
Description
Test:  applications/jcstress/threadlocal.java	

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (c:\sb\prod\1738969254\workspace\open\src\hotspot\share\gc/g1/g1ParScanThreadState.inline.hpp:148), pid=59968, tid=63216
#  assert(!_g1h->heap_region_containing(p)->is_survivor()) failed: Should have filtered out from-newly allocated survivor references already.
#
# JRE version: Java(TM) SE Runtime Environment (25.0+10) (fastdebug build 25-ea+10-LTS-1004)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 25-ea+10-LTS-1004, mixed mode, sharing, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
# Problematic frame:
# V  [jvm.dll+0x7824d1]  G1ParScanThreadState::enqueue_card_if_tracked<enum narrowOop>+0x391
#
# Core dump will be written. Default location: C:\sb\prod\1739040586\testoutput\test-support\jtreg_open_test_hotspot_jtreg_jcstress_part3\scratch\hs_err_pid59968.mdmp
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#

---------------  S U M M A R Y ------------

Command Line: -XX:+UnlockDiagnosticVMOptions -XX:-UsePerfData -Xms256M -Xmx256M -XX:+AlwaysPreTouch -XX:ParallelGCThreads=2 -XX:ConcGCThreads=2 -XX:G1ConcRefinementThreads=2 -XX:CICompilerCount=2 -XX:-RestrictContended -XX:+DebugNonSafepoints -XX:-VerifyBeforeExit -XX:-EnableThreadSMRStatistics -XX:-ZapUnusedHeapArea -XX:-ZapTLAB -XX:-ZapFillerObjects -XX:-ZapResourceArea -XX:-ZapVMHandleArea -XX:-ZapStackSegments -XX:-VerifyDependencies -Djava.io.tmpdir=C:\sb\prod\1739040586\testoutput\test-support\jtreg_open_test_hotspot_jtreg_jcstress_part3\scratch -Djava.io.tmpdir=C:\sb\prod\1739040586\testoutput\test-support\jtreg_open_test_hotspot_jtreg_jcstress_part3\scratch -XX:MaxRAMPercentage=25 -Dtest.boot.jdk=c:\ade\mesos\work_dir\jib-master\install\jdk\23\37\bundles\windows-x64\jdk-23_windows-x64_bin.zip\jdk-23 -Djava.io.tmpdir=c:\sb\prod\1739040586\testoutput\test-support\jtreg_open_test_hotspot_jtreg_jcstress_part3\tmp -XX:+CreateCoredumpOnCrash -XX:-TieredCompilation -XX:+HeapDumpOnOutOfMemoryError -XX:+CrashOnOutOfMemoryError -XX:CompilerDirectivesFile=C:\sb\prod\1739040586\testoutput\test-support\jtreg_open_test_hotspot_jtreg_jcstress_part3\scratch\jcstress17165729612027668916directives org.openjdk.jcstress.ForkedMain false 127.0.0.1 57688 1

Host: AMD EPYC 7J13 64-Core Processor                , 12 cores, 23G,  Windows Server 2019 , 64 bit Build 17763 (10.0.17763.6292)
Time: Sat Feb  8 20:13:56 2025 Etc elapsed time: 44.085595 seconds (0d 0h 0m 44s)

---------------  T H R E A D  ---------------

Current thread (0x00000141b09ba1b0):  WorkerThread "GC Thread#0"    [id=63216, stack(0x00000013a3d00000,0x00000013a3e00000) (1024K)]

Stack: [0x00000013a3d00000,0x00000013a3e00000],  sp=0x00000013a3dff230,  free space=1020k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [jvm.dll+0x7824d1]  G1ParScanThreadState::enqueue_card_if_tracked<enum narrowOop>+0x391  (g1ParScanThreadState.inline.hpp:148)
V  [jvm.dll+0x793c07]  G1ScanCardClosure::do_oop_work<enum narrowOop>+0x227  (g1OopClosures.inline.hpp:185)
V  [jvm.dll+0x7a70c8]  G1ScanRSForOptionalClosure::do_oop+0x68  (g1OopClosures.hpp:84)
V  [jvm.dll+0x780661]  G1OopStarChunkedList::chunks_do<enum narrowOop>+0x91  (g1OopStarChunkedList.inline.hpp:80)
V  [jvm.dll+0x7807eb]  G1OopStarChunkedList::oops_do+0x6b  (g1OopStarChunkedList.cpp:41)
V  [jvm.dll+0x7a6bfd]  G1ScanOptionalRemSetRootsClosure::do_heap_region+0xbd  (g1RemSet.cpp:845)
V  [jvm.dll+0x71465b]  G1CollectedHeap::par_iterate_regions_array+0x15b  (g1CollectedHeap.cpp:2010)
V  [jvm.dll+0x71cedf]  G1CollectionSet::iterate_incremental_part_from+0x4f  (g1CollectionSet.cpp:174)
V  [jvm.dll+0x7a8a90]  G1RemSet::scan_collection_set_optional_roots+0x110  (g1RemSet.cpp:874)
V  [jvm.dll+0x7b9c18]  G1EvacuateOptionalRegionsTask::scan_roots+0x88  (g1YoungCollector.cpp:757)
V  [jvm.dll+0x7b9f65]  G1EvacuateRegionsBaseTask::work+0x75  (g1YoungCollector.cpp:657)
V  [jvm.dll+0x109fc37]  WorkerThread::run+0x97  (workerThread.cpp:200)
V  [jvm.dll+0xfaa634]  Thread::call_run+0x1b4  (thread.cpp:236)
V  [jvm.dll+0xd6bfc1]  thread_native_entry+0xe1  (os_windows.cpp:566)
C  [ucrtbase.dll+0x2268a]  (no source info available)
C  [KERNEL32.DLL+0x17ac4]  (no source info available)
C  [ntdll.dll+0x5a8c1]  (no source info available)




Comments
Test: tools/javac/lambda/bytecode/TestLambdaBytecodeTargetRelease14.java # # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (/opt/mach5/mesos/work_dir/slaves/03ecc23a-edd5-4bb5-a333-4ff8ea07fd7c-S1845/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/ceb43634-c7ca-4ee1-9ec7-dbd2ab8b0a07/runs/0ed7f17a-81bb-4d4e-aa90-af06f03c5f2a/workspace/open/src/hotspot/share/gc/g1/g1ParScanThreadState.inline.hpp:148), pid=2616448, tid=2616621 # assert(!_g1h->heap_region_containing(p)->is_survivor()) failed: Should have filtered out from-newly allocated survivor references already. # # JRE version: Java(TM) SE Runtime Environment (25.0+11) (fastdebug build 25-ea+11-LTS-1152) # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 25-ea+11-LTS-1152, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64) # Problematic frame: # V [libjvm.so+0xda1bde] void G1ScanCardClosure::do_oop_work<narrowOop>(narrowOop*)+0x61e # # Core dump will be written. Default location: Core dumps may be processed with "/opt/core.sh %p" (or dumping to /opt/mach5/mesos/work_dir/slaves/03ecc23a-edd5-4bb5-a333-4ff8ea07fd7c-S1742/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/3251b00f-2472-4778-8d8a-fa222d8bcab4/runs/9d4df3c6-7ade-4a86-963e-8dea687bc1bc/testoutput/test-support/jtreg_open_test_langtools_tier1/scratch/3/core.2616448) # # If you would like to submit a bug report, please visit: # https://bugreport.java.com/bugreport/crash.jsp # --------------- S U M M A R Y ------------ Command Line: -Xmx768m -XX:MaxRAMPercentage=4.16667 -Dtest.boot.jdk=/opt/mach5/mesos/work_dir/jib-master/install/jdk/23/37/bundles/linux-x64/jdk-23_linux-x64_bin.tar.gz/jdk-23 -Djava.io.tmpdir=/opt/mach5/mesos/work_dir/slaves/03ecc23a-edd5-4bb5-a333-4ff8ea07fd7c-S1742/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/3251b00f-2472-4778-8d8a-fa222d8bcab4/runs/9d4df3c6-7ade-4a86-963e-8dea687bc1bc/testoutput/test-support/jtreg_open_test_langtools_tier1/tmp -ea -esa -Duse.JTREG_TEST_THREAD_FACTORY=Virtual -XX:-VerifyContinuations -Djtreg.test.thread.factory=Virtual --patch-module=java.base=/opt/mach5/mesos/work_dir/slaves/03ecc23a-edd5-4bb5-a333-4ff8ea07fd7c-S1742/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/3251b00f-2472-4778-8d8a-fa222d8bcab4/runs/9d4df3c6-7ade-4a86-963e-8dea687bc1bc/testoutput/test-support/jtreg_open_test_langtools_tier1/patches/java.base -Djava.security.policy=file:/opt/mach5/mesos/work_dir/slaves/03ecc23a-edd5-4bb5-a333-4ff8ea07fd7c-S1742/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/3251b00f-2472-4778-8d8a-fa222d8bcab4/runs/9d4df3c6-7ade-4a86-963e-8dea687bc1bc/./testoutput/test-support/jtreg_open_test_langtools_tier1/jtreg.policy com.sun.javatest.regtest.agent.AgentServer -id 8 -logfile /opt/mach5/mesos/work_dir/slaves/03ecc23a-edd5-4bb5-a333-4ff8ea07fd7c-S1742/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/3251b00f-2472-4778-8d8a-fa222d8bcab4/runs/9d4df3c6-7ade-4a86-963e-8dea687bc1bc/testoutput/test-support/jtreg_open_test_langtools_tier1/jtData/agentServer.8.trace -allowSetSecurityManager -port 44845 -timeoutFactor 4.0 -testThreadFactory Virtual -testThreadFactoryPath /opt/mach5/mesos/work_dir/jib-master/install/jdk-25+11-1152/linux-x64-debug.test/jtreg_test_thread_factory/jtregTestThreadFactory.jar Host: AMD EPYC 7J13 64-Core Processor, 12 cores, 23G, Oracle Linux Server release 8.10 Time: Tue Feb 18 03:09:04 2025 UTC elapsed time: 984.341512 seconds (0d 0h 16m 24s) --------------- T H R E A D --------------- Current thread (0x00007f3fec013bb0): WorkerThread "GC Thread#8" [id=2616621, stack(0x00007f3fda214000,0x00007f3fda314000) (1024K)] Stack: [0x00007f3fda214000,0x00007f3fda314000], sp=0x00007f3fda312a50, free space=1018k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.so+0xda1bde] void G1ScanCardClosure::do_oop_work<narrowOop>(narrowOop*)+0x61e (g1ParScanThreadState.inline.hpp:148) V [libjvm.so+0xda1c9c] G1ScanRSForOptionalClosure::do_oop(narrowOop*)+0x5c (g1OopClosures.inline.hpp:196) V [libjvm.so+0xd79296] unsigned long G1OopStarChunkedList::chunks_do<narrowOop>(ChunkedList<narrowOop*, (MemTag)5>*, OopClosure*) [clone .isra.0]+0x76 (g1OopStarChunkedList.inline.hpp:82) V [libjvm.so+0xd7998d] G1OopStarChunkedList::oops_do(OopClosure*, OopClosure*)+0x4d (g1OopStarChunkedList.cpp:39) V [libjvm.so+0xd9a630] G1ScanOptionalRemSetRootsClosure::do_heap_region(G1HeapRegion*)+0xb0 (g1RemSet.cpp:828) V [libjvm.so+0xcdf1a8] G1CollectedHeap::par_iterate_regions_array(G1HeapRegionClosure*, G1HeapRegionClaimer*, unsigned int const*, unsigned long, unsigned int) const+0x158 (g1CollectedHeap.cpp:2009) V [libjvm.so+0xd96ab0] G1RemSet::scan_collection_set_optional_roots(G1ParScanThreadState*, unsigned int, G1GCPhaseTimes::GCParPhases, G1GCPhaseTimes::GCParPhases)+0x110 (g1CollectedHeap.hpp:1132) V [libjvm.so+0xdc83b7] G1EvacuateRegionsBaseTask::work(unsigned int)+0x87 (g1YoungCollector.cpp:656) V [libjvm.so+0x19d6b30] WorkerThread::run()+0x80 (workerThread.cpp:69) V [libjvm.so+0x18913d6] Thread::call_run()+0xb6 (thread.cpp:231) V [libjvm.so+0x1569538] thread_native_entry(Thread*)+0x128 (os_linux.cpp:877)
18-02-2025

Some more of those crashes "assert(!_g1h->heap_region_containing(p)->is_survivor()) failed: Should have filtered out from-newly allocated survivor references already." have been observed on Windows x86_64 and on Linux Alpine x86_64.
17-02-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/23568 Date: 2025-02-11 18:33:42 +0000
11-02-2025

We observed a similar issue , seen on macOS x86_64 : # Internal Error (/priv/jenkins/client-home/workspace/openjdk-jdk-weekly-macos_x86_64-dbg/jdk/src/hotspot/share/gc/g1/g1ParScanThreadState.inline.hpp:148), pid=51238, tid=42499 # assert(!_g1h->heap_region_containing(p)->is_survivor()) failed: Should have filtered out from-newly allocated survivor references already. # # JRE version: OpenJDK Runtime Environment (25.0) (fastdebug build 25-internal-adhoc.sapmachine.jdk) --------------- T H R E A D --------------- Current thread (0x00007fd2a28285e0): WorkerThread "GC Thread#6" [id=42499, stack(0x000070000bd7a000,0x000070000be7a000) (1024K)] Stack: [0x000070000bd7a000,0x000070000be7a000], sp=0x000070000be79900, free space=1022k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.dylib+0x1472c5b] VMError::report(outputStream*, bool)+0x1e3b (g1ParScanThreadState.inline.hpp:148) V [libjvm.dylib+0x147677b] VMError::report_and_die(int, char const*, char const*, __va_list_tag*, Thread*, unsigned char*, void const*, void const*, char const*, int, unsigned long)+0x59b V [libjvm.dylib+0x6c27cd] report_vm_error(char const*, int, char const*, char const*, ...)+0xcd V [libjvm.dylib+0x8b81cb] void G1ParScanThreadState::enqueue_card_if_tracked<narrowOop>(G1HeapRegionAttr, narrowOop*, oop)+0x2bb V [libjvm.dylib+0x8cb318] void G1ScanCardClosure::do_oop_work<narrowOop>(narrowOop*)+0x268 V [libjvm.dylib+0x8cc660] G1ScanRSForOptionalClosure::do_oop(narrowOop*)+0x60 V [libjvm.dylib+0x8afdf8] unsigned long G1OopStarChunkedList::chunks_do<narrowOop>(ChunkedList<narrowOop*, (MemTag)5>*, OopClosure*)+0x88 V [libjvm.dylib+0x8afc79] G1OopStarChunkedList::oops_do(OopClosure*, OopClosure*)+0x59 V [libjvm.dylib+0x8cc488] G1ScanOptionalRemSetRootsClosure::scan_opt_rem_set_roots(G1HeapRegion*)+0x128 V [libjvm.dylib+0x8cc34f] G1ScanOptionalRemSetRootsClosure::do_heap_region(G1HeapRegion*)+0xf V [libjvm.dylib+0x822b9c] G1CollectedHeap::par_iterate_regions_array(G1HeapRegionClosure*, G1HeapRegionClaimer*, unsigned int const*, unsigned long, unsigned int) const+0x13c V [libjvm.dylib+0x8c7fc2] G1RemSet::scan_collection_set_optional_roots(G1ParScanThreadState*, unsigned int, G1GCPhaseTimes::GCParPhases, G1GCPhaseTimes::GCParPhases)+0xf2 V [libjvm.dylib+0x8f790b] G1EvacuateRegionsBaseTask::work(unsigned int)+0x7b V [libjvm.dylib+0x14eb1d7] WorkerThread::run()+0x77 V [libjvm.dylib+0x13c10dc] Thread::call_run()+0xbc V [libjvm.dylib+0xf89777] thread_native_entry(Thread*)+0x137 C [libsystem_pthread.dylib+0x618b] _pthread_start+0x63 C [libsystem_pthread.dylib+0x1ae3] thread_start+0xf
11-02-2025

Test vmTestbase/vm/gc/concurrent/lp50yp10rp70mr30st300t1/TestDescription.java was observed the same failure on linux-aarch64. Starting Thread[#95,vm.gc.concurrent.Concurrent$Worker@530a298a,5,MainThreadGroup] # # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (src/hotspot/share/gc/g1/g1ParScanThreadState.inline.hpp:148), pid=78558, tid=78630 # assert(!_g1h->heap_region_containing(p)->is_survivor()) failed: Should have filtered out from-newly allocated survivor references already. # # JRE version: OpenJDK Runtime Environment (25.0) (fastdebug build 25-internal-d104debe) # Java VM: OpenJDK 64-Bit Server VM (fastdebug 25-internal-d104debe, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-aarch64) # Problematic frame: # V [libjvm.so+0xc667ec] void G1ScanCardClosure::do_oop_work<narrowOop>(narrowOop*)+0x63c
11-02-2025