In one of our internal tests we have found this deadlock:
0) Various threads are waiting for the GC to hand out freed memory.
1) The GC is blocked on the Service_lock:
Mutex::lock_without_safepoint_check()
OopMapCache::trigger_cleanup()
ZGenerationYoung::pause_relocate_start()
ZGenerationYoung::collect(ZYoungType, ConcurrentGCTimer*)
ZDriverMinor::gc(ZDriverRequest const&)
ZThread::run_service()
2) The Service_lock is held by the ServiceThread, which is stalling because it is waiting for the GC to give it memory
PlatformMonitor::wait(unsigned long)
ZRelocateQueue::add_and_wait(ZForwarding*)
ZRelocate::relocate_object(ZForwarding*, zaddress_unsafe)
ZUncoloredRootProcessWeakOopClosure::do_root(zaddress_unsafe*)
ZNMethod::nmethod_oops_do_inner(nmethod*, OopClosure*)
ZBarrierSetNMethod::nmethod_entry_barrier(nmethod*)
JvmtiDeferredEventQueue::oops_do(OopClosure*, NMethodClosure*)
// vvv Lock taken in this frame vvv
ServiceThread::oops_do_no_frames(OopClosure*, NMethodClosure*)
ZStackWatermark::process_head(void*)
ZStackWatermark::start_processing_impl(void*)
StackWatermark::start_processing()
StackWatermark::on_safepoint()
SafepointMechanism::process(JavaThread*, bool, bool)
StringTable::clean_dead_entries(JavaThread*)
StringTable::do_concurrent_work(JavaThread*)
ServiceThread::service_thread_entry