The TestCodeCacheRemSet_test() executes G1CodeRootSet::test(), which starts out with an assert that assumes that no chunks has been requested by the compiler yet:
assert(_num_chunks_handed_out == 0, "No elements must have been handed out yet");
However, this means that the test is competing with the compiler thread. It does not always win this race. On my OSX laptop I always get this failure:
$ java -XX:+ExecuteInternalVMTests -XX:+UseG1GC -version
Running internal VM tests
Running test: TestReservedSpace_test()
Running test: TestReserveMemorySpecial_test()
Running test: TestVirtualSpace_test()
Running test: TestMetaspaceAux_test()
Running test: TestMetachunk_test()
Running test: TestVirtualSpaceNode_test()
Running test: GlobalDefinitions::test_globals()
Running test: GCTimerAllTest::all()
Running test: arrayOopDesc::test_max_array_length()
Running test: CollectedHeap::test_is_in()
Running test: QuickSort::test_quick_sort()
Running test: AltHashing::test_alt_hash()
Running test: test_loggc_filename()
Running test: TestNewSize_test()
Running test: TestOldSize_test()
Java HotSpot(TM) 64-Bit Server VM warning: Inconsistency between maximum heap size and maximum generation sizes: using maximum heap = 188743680 -XX:OldSize flag is being ignored
Java HotSpot(TM) 64-Bit Server VM warning: Inconsistency between generation sizes and heap size, resizing the generations to fit the heap.
Running test: TestKlass_test()
Running test: TestBitMap_test()
Running test: VMStructs::test()
Running test: TestOldFreeSpaceCalculation_test()
Running test: TestG1BiasedArray_test()
Running test: HeapRegionRemSet::test_prt()
Running test: TestBufferingOopClosure_test()
Running test: TestCodeCacheRemSet_test()
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc: SuppressErrorAt=/g1CodeCacheRemSet.cpp:200
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/Users/brutisso/repos/hs-gc9/src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp:200), pid=22174, tid=6403
# assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
#
# JRE version: Java(TM) SE Runtime Environment (8.0-b107) (build 1.8.0-ea-b107)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.0-b62-internal-fastdebug mixed mode bsd-amd64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/brutisso/repos/hs-gc9/hs_err_pid22174.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#
On my Linux workstation the test almost always passes, but if I add -Xcomp the test always fails:
$ java -Xcomp -XX:+UseG1GC -XX:+ExecuteInternalVMTests -version
Running internal VM tests
Running test: TestReservedSpace_test()
Running test: TestReserveMemorySpecial_test()
Running test: TestVirtualSpace_test()
Running test: TestMetaspaceAux_test()
Running test: TestMetachunk_test()
Running test: TestVirtualSpaceNode_test()
Running test: GlobalDefinitions::test_globals()
Running test: GCTimerAllTest::all()
Running test: arrayOopDesc::test_max_array_length()
Running test: CollectedHeap::test_is_in()
Running test: QuickSort::test_quick_sort()
Running test: AltHashing::test_alt_hash()
Running test: test_loggc_filename()
Running test: TestNewSize_test()
Running test: TestOldSize_test()
Java HotSpot(TM) 64-Bit Server VM warning: Inconsistency between maximum heap size and maximum generation sizes: using maximum heap = 188743680 -XX:OldSize flag is being ignored
Java HotSpot(TM) 64-Bit Server VM warning: Inconsistency between generation sizes and heap size, resizing the generations to fit the heap.
Running test: TestKlass_test()
Running test: TestBitMap_test()
Running test: VMStructs::test()
Running test: TestOldFreeSpaceCalculation_test()
Running test: TestG1BiasedArray_test()
Running test: HeapRegionRemSet::test_prt()
Running test: TestBufferingOopClosure_test()
Running test: TestCodeCacheRemSet_test()
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc: SuppressErrorAt=/g1CodeCacheRemSet.cpp:200
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/localhome/repos/hs-gc9-temp/src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp:200), pid=7014, tid=140676786120448
# assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
#
# JRE version: Java(TM) SE Runtime Environment (8.0-b115) (build 1.8.0-ea-b115)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.0-b62-internal-fastdebug compiled mode linux-amd64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /localhome/repos/hs-gc9-temp/hs_err_pid7014.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#
The test was just recently added by this changeset as a fix for JDK-8035406:
http://hg.openjdk.java.net/jdk9/hs-gc/hotspot/rev/7c383fe0d35a