changeset 49408:58fdb6c2a274

8199272: Broken assertion in ClassLoaderData::remove_handle Summary: Added new ClassLoaderData::ChunkList::contains(oop*) function for OopHandle rather than oop. Reviewed-by: stefank, hseigel
author coleenp
date Thu, 15 Mar 2018 07:40:00 -0400
parents 64156c70746c
children 911e32d49f76
files src/hotspot/share/classfile/classLoaderData.cpp src/hotspot/share/classfile/classLoaderData.hpp
diffstat 2 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/classfile/classLoaderData.cpp	Thu Mar 15 07:20:32 2018 +0100
+++ b/src/hotspot/share/classfile/classLoaderData.cpp	Thu Mar 15 07:40:00 2018 -0400
@@ -222,6 +222,19 @@
   return cl.found();
 }
 
+#ifndef PRODUCT
+bool ClassLoaderData::ChunkedHandleList::owner_of(oop* oop_handle) {
+  Chunk* chunk = _head;
+  while (chunk != NULL) {
+    if (&(chunk->_data[0]) <= oop_handle && oop_handle < &(chunk->_data[chunk->_size])) {
+      return true;
+    }
+    chunk = chunk->_next;
+  }
+  return false;
+}
+#endif // PRODUCT
+
 bool ClassLoaderData::claim() {
   if (_claimed == 1) {
     return false;
@@ -759,7 +772,7 @@
   assert(!is_unloading(), "Do not remove a handle for a CLD that is unloading");
   oop* ptr = h.ptr_raw();
   if (ptr != NULL) {
-    assert(_handles.contains(*ptr), "Got unexpected handle " PTR_FORMAT, p2i(ptr));
+    assert(_handles.owner_of(ptr), "Got unexpected handle " PTR_FORMAT, p2i(ptr));
     // This root is not walked in safepoints, and hence requires an appropriate
     // decorator that e.g. maintains the SATB invariant in SATB collectors.
     RootAccess<IN_CONCURRENT_ROOT>::oop_store(ptr, oop(NULL));
--- a/src/hotspot/share/classfile/classLoaderData.hpp	Thu Mar 15 07:20:32 2018 +0100
+++ b/src/hotspot/share/classfile/classLoaderData.hpp	Thu Mar 15 07:40:00 2018 -0400
@@ -205,6 +205,7 @@
     // However, multiple threads can execute oops_do concurrently with add.
     oop* add(oop o);
     bool contains(oop p);
+    NOT_PRODUCT(bool owner_of(oop* p);)
     void oops_do(OopClosure* f);
 
     int count() const;