src/hotspot/share/memory/allocation.cpp
changeset 54437 2ae93028bef3
parent 53703 24341625d8f2
child 54786 ebf733a324d4
--- a/src/hotspot/share/memory/allocation.cpp	Fri Apr 05 09:18:18 2019 +0200
+++ b/src/hotspot/share/memory/allocation.cpp	Wed Mar 27 14:13:34 2019 +0100
@@ -84,8 +84,14 @@
   return Metaspace::allocate(loader_data, word_size, type, THREAD);
 }
 
-bool MetaspaceObj::is_metaspace_object() const {
-  return Metaspace::contains((void*)this);
+bool MetaspaceObj::is_valid(const MetaspaceObj* p) {
+  // Weed out obvious bogus values first without traversing metaspace
+  if ((size_t)p < os::min_page_size()) {
+    return false;
+  } else if (!is_aligned((address)p, sizeof(MetaWord))) {
+    return false;
+  }
+  return Metaspace::contains((void*)p);
 }
 
 void MetaspaceObj::print_address_on(outputStream* st) const {