Description
https://github.com/openjdk/jdk/blob/f1a24f6d4827f9b8648dd2afe6d606dab67d51fe/src/hotspot/share/cds/metaspaceShared.cpp#L786-L795
if (CDSConfig::is_dumping_heap()) {
StringTable::allocate_shared_strings_array(CHECK);
if (!HeapShared::is_archived_boot_layer_available(THREAD)) {
log_info(cds)("archivedBootLayer not available, disabling full module graph");
CDSConfig::disable_dumping_full_module_graph();
}
HeapShared::init_for_dumping(CHECK);
ArchiveHeapWriter::init();
if (CDSConfig::is_dumping_full_module_graph()) {
HeapShared::reset_archived_object_states(CHECK);
}
StringTable::allocate_shared_strings_array() creates an Java object array that has the same size as the number of currently interned strings.
However, the few lines below the call can invoke Java code, causing more strings to be interned.
In the Leyden repo, this has lead to an assert due to overflowing of the shared_strings_array.
****************
The fix is to move the call to where we know that no more Java code would be executed.
if (CDSConfig::is_dumping_heap()) {
StringTable::allocate_shared_strings_array(CHECK);
if (!HeapShared::is_archived_boot_layer_available(THREAD)) {
log_info(cds)("archivedBootLayer not available, disabling full module graph");
CDSConfig::disable_dumping_full_module_graph();
}
HeapShared::init_for_dumping(CHECK);
ArchiveHeapWriter::init();
if (CDSConfig::is_dumping_full_module_graph()) {
HeapShared::reset_archived_object_states(CHECK);
}
StringTable::allocate_shared_strings_array() creates an Java object array that has the same size as the number of currently interned strings.
However, the few lines below the call can invoke Java code, causing more strings to be interned.
In the Leyden repo, this has lead to an assert due to overflowing of the shared_strings_array.
****************
The fix is to move the call to where we know that no more Java code would be executed.