Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8356233

NMT: tty->print_cr should not be used in VirtualMemoryTracker::add_reserved_region()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • None
    • hotspot

      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

            Unassigned Unassigned
            ccheung Calvin Cheung
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: