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

NMT: assert on registering a region which completely engulfs an existing region

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 17
    • 11, 16, 17
    • hotspot
    • b15

    Description

      I am testing a prototype for JDK-8256844 which makes NMT late initializable.

      It works, and one of the benefits is that we now can run gtests with NMT enabled.

      Which exercises NMT in new ways. We promptly crash in the metaspace tests, which do a lot of arbitrary, random, but entirely valid range commits as part of the VirtualSpaceNode stress tests:

      ```
      [ RUN ] metaspace.virtual_space_node_test_5_vm
      # To suppress the following error report, specify this argument
      # after -XX: or in .hotspotrc: SuppressErrorAt=/virtualMemoryTracker.hpp:243
      assert failed: assert(rgn.base() >= end()) failed: Sanity#
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # Internal Error (/shared/projects/openjdk/jdk-jdk/source/src/hotspot/share/services/virtualMemoryTracker.hpp:243), pid=183572, tid=183572
      # assert(rgn.base() >= end()) failed: Sanity
      #
      ```
      Stack:
      ```
      (gdb) bt
      #0 0x00007ffff5b36cca in VirtualMemoryRegion::compare (this=0x555555b02278, rgn=...) at /shared/projects/openjdk/jdk-jdk/source/src/hotspot/share/services/virtualMemoryTracker.hpp:243
      #1 0x00007ffff6cf6823 in compare_committed_region (r1=..., r2=...) at /shared/projects/openjdk/jdk-jdk/source/src/hotspot/share/services/virtualMemoryTracker.cpp:55
      #2 0x00007ffff5b39ee3 in SortedLinkedList<CommittedMemoryRegion, &(compare_committed_region(CommittedMemoryRegion const&, CommittedMemoryRegion const&)), (ResourceObj::allocation_type)2, (MEMFLAGS)11, (AllocFailStrategy::AllocFailEnum)1>::add (this=0x555555b020b8,
          node=0x555555b02300) at /shared/projects/openjdk/jdk-jdk/source/src/hotspot/share/utilities/linkedlist.hpp:389
      #3 0x00007ffff5b39346 in LinkedListImpl<CommittedMemoryRegion, (ResourceObj::allocation_type)2, (MEMFLAGS)11, (AllocFailStrategy::AllocFailEnum)1>::add (this=0x555555b020b8, e=...) at /shared/projects/openjdk/jdk-jdk/source/src/hotspot/share/utilities/linkedlist.hpp:167
      #4 0x00007ffff5b39157 in SortedLinkedList<CommittedMemoryRegion, &(compare_committed_region(CommittedMemoryRegion const&, CommittedMemoryRegion const&)), (ResourceObj::allocation_type)2, (MEMFLAGS)11, (AllocFailStrategy::AllocFailEnum)1>::add (this=0x555555b020b8, e=...)
          at /shared/projects/openjdk/jdk-jdk/source/src/hotspot/share/utilities/linkedlist.hpp:370
      #5 0x00007ffff6cfa07b in ReservedMemoryRegion::add_committed_region (this=0x555555b020a8, rgn=...) at /shared/projects/openjdk/jdk-jdk/source/src/hotspot/share/services/virtualMemoryTracker.hpp:355
      ...
      (gdb) p *this
      $1 = {_base_address = 0x7fffb24c0000 "", _size = 1179648}
      (gdb) p rgn
      $2 = (const VirtualMemoryRegion &) @0x555555b02318: {_base_address = 0x7fffb2460000 "", _size = 2424832}
      ```
      As we can see, the new committed to-be-registered region [0x7fffb2460000...7FFFB26B0000) completely engulfs an existing region [0x7fffb24c0000...0x7FFFB25E0000).

      This triggers an assert in VirtualMemoryRegion:

      ```
        inline int compare(const VirtualMemoryRegion& rgn) const {
          if (overlap_region(rgn.base(), rgn.size())) {
            return 0;
          } else if (base() >= rgn.end()) {
            return 1;
          } else {
            assert(rgn.base() >= end(), "Sanity"); <<<
            return -1;
          }
        }
      ```
      which calls
      ```
        inline bool overlap_region(address addr, size_t sz) const {
          assert(sz > 0, "Invalid size");
          assert(size() > 0, "Invalid size");
          return contain_address(addr) ||
                 contain_address(addr + sz - 1);
        }
      ```

      but VirtualMemoryRegion::overlap_region does not handle the engulfing case correctly.

      Attachments

        Issue Links

          Activity

            People

              stuefe Thomas Stuefe
              stuefe Thomas Stuefe
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: