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

CodeCache.findBlobUnsafe(addr) sometimes asserts with valid address

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 15
    • Fix Version/s: 16
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b03

      Description

      While doing a lot of SA debugging, which included adding code that did frequent lookups of random register values in the the CodeCache, on occasion I would see the following assert triggered in CodeCache.findBlobUnsafe():

          if (Assert.ASSERTS_ENABLED) {
            // The HeapBlock that contains this blob is outside of the blob
            // but it shouldn't be an error to find a blob based on the
            // pointer to the HeapBlock.
            Assert.that(result.blobContains(start) || result.blobContains(start.addOffsetTo(8)),
                              "found wrong CodeBlob");

          }

      This is asserting that the CodeBlob found really does contain the address being looked up. After dumping the contents of the CodeBlob to see why it sometimes asserts, it became apparent that the address provided is always 16 bytes before the start of the CodeBlob. The check for result.blobContains(start.addOffsetTo(8)) is there in case you are dealing with a pointer to the HeapBlock that was allocated for the CodeBlob. The HeapBlock has a header, and the CodeBlob starts after the header. For 32 bit systems the header is 8 bytes. For 64-bit it is 16 bytes. Using (2 * addressSize) seems to be the simplest fix.

      https://hg.openjdk.java.net/jdk/jdk/file/87828d2e32fe/src/hotspot/share/memory/heap.hpp#l35
      https://hg.openjdk.java.net/jdk/jdk/file/87828d2e32fe/src/hotspot/share/memory/heap.cpp#l283

        Attachments

          Activity

            People

            Assignee:
            cjplummer Chris Plummer
            Reporter:
            cjplummer Chris Plummer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: