changeset 59830:431d17e9235f

8246369: CodeCache.findBlobUnsafe(addr) sometimes asserts with valid address Reviewed-by: sspitsyn, amenkov
author cjplummer
date Wed, 17 Jun 2020 13:12:54 -0700
parents 62c8fc2cd507
children d2484d771ea9
files src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeCache.java
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeCache.java	Wed Jun 17 13:00:14 2020 -0700
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeCache.java	Wed Jun 17 13:12:54 2020 -0700
@@ -132,11 +132,13 @@
     }
     if (result == null) return null;
     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");
+      // The pointer to 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.
+      // The heap block header is padded out to an 8-byte boundary. See heap.hpp. The
+      // simplest way to compute the header size is just 2 * addressSize.
+      Assert.that(result.blobContains(start) ||
+                  result.blobContains(start.addOffsetTo(2 * VM.getVM().getAddressSize())),
+                  "found wrong CodeBlob");
     }
     return result;
   }