8223391: Unsynchronized iteration of ClassLoaderDataGraph
authorcoleenp
Wed, 08 May 2019 06:40:45 -0400
changeset 54756 845f5a35241b
parent 54755 de34f4b370b0
child 54757 6c1a7c2ee530
8223391: Unsynchronized iteration of ClassLoaderDataGraph Summary: lock in G1 before clear_claimed_marks Reviewed-by: hseigel, lfoltan, tschatzl
src/hotspot/share/classfile/classLoaderDataGraph.cpp
src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp
--- a/src/hotspot/share/classfile/classLoaderDataGraph.cpp	Wed May 08 11:59:14 2019 +0200
+++ b/src/hotspot/share/classfile/classLoaderDataGraph.cpp	Wed May 08 06:40:45 2019 -0400
@@ -48,6 +48,7 @@
 volatile size_t ClassLoaderDataGraph::_num_instance_classes = 0;
 
 void ClassLoaderDataGraph::clear_claimed_marks() {
+  assert_locked_or_safepoint_weak(ClassLoaderDataGraph_lock);
   for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
     cld->clear_claim();
   }
--- a/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp	Wed May 08 11:59:14 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp	Wed May 08 06:40:45 2019 -0400
@@ -268,6 +268,7 @@
 
       {
         G1ConcPhase p(G1ConcurrentPhase::CLEAR_CLAIMED_MARKS, this);
+        MutexLocker ml(ClassLoaderDataGraph_lock);
         ClassLoaderDataGraph::clear_claimed_marks();
       }