This bug was exposed after JDK-8282191.
Reproduce:
run java/foreign/TestIntrinsics.java fails with -XX:+UseShenandoahGC
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/home/jvm/jdk/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp:485), pid=42328, tid=42345
# assert(GCCause::is_user_requested_gc(cause) || GCCause::is_serviceability_requested_gc(cause) || cause == GCCause::_metadata_GC_clear_soft_refs || cause == GCCause::_full_gc_alot || cause == GCCause::_wb_full_gc || cause == GCCause::_wb_breakpoint || cause == GCCause::_scavenge_alot) failed: only requested GCs here
#
# JRE version: OpenJDK Runtime Environment (19.0) (fastdebug build 19-internal-adhoc.jvm.jdk513)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 19-internal-adhoc.jvm.jdk513, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, shenandoah gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0x16f3724] ShenandoahControlThread::request_gc(GCCause::Cause)+0x224
#
Current thread (0x00007f852427d060): JavaThread "Sweeper thread" daemon [_thread_in_vm, id=101859, stack(0x00007f84fe6ff000,0x00007f84fe800000)]
Stack: [0x00007f84fe6ff000,0x00007f84fe800000], sp=0x00007f84fe7fec20, free space=1023k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x126f367] ShenandoahControlThread::request_gc(GCCause::Cause)+0x69
V [libjvm.so+0x1283911] ShenandoahHeap::collect(GCCause::Cause)+0x2b
V [libjvm.so+0x13a0709] NMethodSweeper::do_stack_scanning()+0x79
V [libjvm.so+0x13a0b5f] NMethodSweeper::sweep()+0x109
V [libjvm.so+0x13a082a] NMethodSweeper::sweeper_loop()+0xb0
V [libjvm.so+0x8dcf5b] CodeCacheSweeperThread::thread_entry(JavaThread*, JavaThread*)+0x15
V [libjvm.so+0x13fd2e5] JavaThread::thread_main_inner()+0x18b
V [libjvm.so+0x13fd14e] JavaThread::run()+0x234
V [libjvm.so+0x13fa6d8] Thread::call_run()+0x180
V [libjvm.so+0x1132af5] thread_native_entry(Thread*)+0x18f