Testing caught a failure in current jdk/jdk, in a rare corner case:
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/home/jenkins/workspace/nightly/jdk-jdk/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp:203), pid=36780, tid=36787
# guarantee(_heap->cancelled_gc()) failed: only valid when evac has been cancelled
--------------- S U M M A R Y ------------
Command Line: -Xmx1g -Xms1g -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:+UnlockDiagnosticVMOptions -XX:ShenandoahGCHeuristics=aggressive -XX:+ShenandoahVerifyOptoBarriers -XX:+ShenandoahOOMDuringEvacALot -XX:CompileCommandFile=/tmp/jmh6571298855984735825compilecommand org.openjdk.jmh.runner.ForkedMain 127.0.0.1 34213
--------------- T H R E A D ---------------
Current thread (0x00007f7de8294800): VMThread "VM Thread" [stack: 0x00007f7dd0132000,0x00007f7dd0232000] [id=36787]
Stack: [0x00007f7dd0132000,0x00007f7dd0232000], sp=0x00007f7dd0230450, free space=1017k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x1637b73] ShenandoahHeapRegion::make_pinned()+0x83
V [libjvm.so+0x1616c48] ShenandoahHeap::sync_pinned_region_status()+0x98
V [libjvm.so+0x161e466] ShenandoahHeap::op_degenerated(ShenandoahHeap::ShenandoahDegenPoint)+0xc6
V [libjvm.so+0x161e94c] ShenandoahHeap::entry_degenerated(int)+0x10c
V [libjvm.so+0x16a5d37] VM_ShenandoahDegeneratedGC::doit()+0x37
V [libjvm.so+0x18a64ed] VM_Operation::evaluate()+0x13d
V [libjvm.so+0x18d611a] VMThread::evaluate_operation(VM_Operation*)+0x15a
V [libjvm.so+0x18d68b5] VMThread::loop()+0x2b5
V [libjvm.so+0x18d6f73] VMThread::run()+0xc3
V [libjvm.so+0x17f268b] Thread::call_run()+0xfb
V [libjvm.so+0x140b609] thread_native_entry(Thread*)+0x119
This says that transition from cset to pinned-cset is invalid when GC was not cancelled. However, this was only true before JDK-8232575 work. Now, this transition is done in sync_pinned_region_status that is supposed to work on all paths. In this case, Degenerated GC dropped the cancelled GC flag already, and thus blows up the check.
The check is excessive and should be removed.