During the investigation on JDK-8356020, I copied some debug tty->print_cr() statements near the end of VirtualMemoryTracker::add_reserved_region() into the following block:
// NMT reports CDS as a whole.
if (reserved_rgn->mem_tag() == mtClassShared) {
log_debug(nmt)("CDS reserved region \'%s\' as a whole (" INTPTR_FORMAT ", %zu)",
reserved_rgn->mem_tag_name(), p2i(reserved_rgn->base()), reserved_rgn->size());
>>>
if (!reserved_rgn->contain_region(base_addr, size)) {
tty->print_cr("Error: existing region: [" INTPTR_FORMAT "-" INTPTR_FORMAT "), memory tag %u.\n"
" new region: [" INTPTR_FORMAT "-" INTPTR_FORMAT "), memory tag %u.",
p2i(reserved_rgn->base()), p2i(reserved_rgn->end()), (unsigned)reserved_rgn->mem_tag(),
p2i(base_addr), p2i(base_addr + size), (unsigned)mem_tag);
}
<<<
assert(reserved_rgn->contain_region(base_addr, size), "Reserved CDS region should contain this mapping region");
return true;
}
and got the following assert failure:
# Internal Error (.../open/src/hotspot/share/runtime/mutex.cpp:457), pid=1088443, tid=1088520
# assert(false) failed: Attempting to acquire lock tty_lock/tty out of order with lock NmtVirtualMemory_lock/service-4 -- possible deadlock
// NMT reports CDS as a whole.
if (reserved_rgn->mem_tag() == mtClassShared) {
log_debug(nmt)("CDS reserved region \'%s\' as a whole (" INTPTR_FORMAT ", %zu)",
reserved_rgn->mem_tag_name(), p2i(reserved_rgn->base()), reserved_rgn->size());
>>>
if (!reserved_rgn->contain_region(base_addr, size)) {
tty->print_cr("Error: existing region: [" INTPTR_FORMAT "-" INTPTR_FORMAT "), memory tag %u.\n"
" new region: [" INTPTR_FORMAT "-" INTPTR_FORMAT "), memory tag %u.",
p2i(reserved_rgn->base()), p2i(reserved_rgn->end()), (unsigned)reserved_rgn->mem_tag(),
p2i(base_addr), p2i(base_addr + size), (unsigned)mem_tag);
}
<<<
assert(reserved_rgn->contain_region(base_addr, size), "Reserved CDS region should contain this mapping region");
return true;
}
and got the following assert failure:
# Internal Error (.../open/src/hotspot/share/runtime/mutex.cpp:457), pid=1088443, tid=1088520
# assert(false) failed: Attempting to acquire lock tty_lock/tty out of order with lock NmtVirtualMemory_lock/service-4 -- possible deadlock