Test case:
i=0; while java \
-XX:MaxRAM=8g -Xshare:dump \
-Xlog:cds,cds+hashtables -Xlog:hashtables \
-XX:SharedArchiveFile=LotsOfClasses.jsa \
-XX:ExtraSharedClassListFile=LotsOfClasses.classlist \
--add-modules ALL-SYSTEM; do
i=$(expr $i + 1);
echo ========================================$i;
done
(See LotsOfClasses.classlist in attachment of this bug)
A deadlock happens between the service thread, which tries to expand the string table, and the VM thread, which tries to iterate over all entries in the string table.
(Note -- VM_PopulateDumpSharedSpace::doit runs inside the VM thread because it wants work on various data structures without worrying about concurrent modifications.)
SERVICE THREAD
#1 os::PlatformEvent::park (this=0x7fcb3c814800)
#2 ParkCommon (timo=0, ev=0x7fcb3c814800)
#3 Monitor::ILock (this=0x7fcb3c016a00, Self=0x7fcb3c8132b0)
#4 Monitor::lock_without_safepoint_check (Self=0x7fcb3c8132b0, this=0x7fcb3c016a00)
#5 Monitor::lock_without_safepoint_check (this=0x7fcb3c016a00)
#6 SafepointSynchronize::block (thread=0x7fcb3c8132b0)
#7 SafepointMechanism::block_if_requested_local_poll (thread=0x7fcb3c8132b0)
#8 SafepointMechanism::block_if_requested (thread=0x7fcb3c8132b0)
#9 ThreadStateTransition::transition_and_fence (to=_thread_blocked, from=_thread_in_vm, thread=0x7fcb3c8132b0)
#10 ThreadStateTransition::trans_and_fence (this=<synthetic pointer>, to=_thread_blocked, from=_thread_in_vm)
#11 ThreadBlockInVM::ThreadBlockInVM (thread=0x7fcb3c8132b0, this=<synthetic pointer>)
#12 StringTable::grow (this=0x7fcb3c161920, jt=jt@entry=0x7fcb3c8132b0)
#13 StringTable::concurrent_work (jt=0x7fcb3c8132b0, this=<optimized out>)
#14 StringTable::do_concurrent_work (jt=jt@entry=0x7fcb3c8132b0)
#15 ServiceThread::service_thread_entry (jt=0x7fcb3c8132b0, __the_thread__=0x7fcb3c8132b0)
#16 JavaThread::thread_main_inner (this=this@entry=0x7fcb3c8132b0)
#17 JavaThread::run (this=0x7fcb3c8132b0)
#18 Thread::call_run (this=0x7fcb3c8132b0)
#19 thread_native_entry (thread=0x7fcb3c8132b0)
#20 start_thread (arg=0x7fcb18b9d700)
#21 clone ()
VM THREAD
#0 ConcurrentHashTable<WeakHandle<(WeakHandleType)2>, StringTableConfig, (MemoryType)9>::lock_resize_lock (locker=0x7fcb3c38db80, this=0x7fcb3c161c30)
#1 ConcurrentHashTable<WeakHandle<(WeakHandleType)2>, StringTableConfig, (MemoryType)9>::do_scan<CopyToArchive> (scan_f=..., thread=0x7fcb3c38db80,
this=0x7fcb3c161c30)
#2 StringTable::copy_shared_string_table (writer=writer@entry=0x7fcb19379820)
#3 StringTable::write_to_archive ()
#4 HeapShared::copy_closed_archive_heap_objects (closed_archive=closed_archive@entry=0x7fcac0f314f0)
#5 HeapShared::archive_java_heap_objects (closed=0x7fcac0f314f0, open=open@entry=0x7fcac0f31550)
#6 VM_PopulateDumpSharedSpace::dump_java_heap_objects (this=this@entry=0x7fcb436c7b90)
#7 VM_PopulateDumpSharedSpace::doit (this=<optimized out>)
#8 VM_Operation::evaluate (this=this@entry=0x7fcb436c7b90)
#9 VMThread::evaluate_operation (this=this@entry=0x7fcb3c38db80, op=0x7fcb436c7b90)
#10 VMThread::loop (this=this@entry=0x7fcb3c38db80)
#11 VMThread::run (this=0x7fcb3c38db80)
#12 Thread::call_run (this=0x7fcb3c38db80)
#13 thread_native_entry (thread=0x7fcb3c38db80)
#14 start_thread (arg=0x7fcb1937a700)