changeset 54756:845f5a35241b

8223391: Unsynchronized iteration of ClassLoaderDataGraph Summary: lock in G1 before clear_claimed_marks Reviewed-by: hseigel, lfoltan, tschatzl
author coleenp
date Wed, 08 May 2019 06:40:45 -0400
parents de34f4b370b0
children 6c1a7c2ee530
files src/hotspot/share/classfile/classLoaderDataGraph.cpp src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp
diffstat 2 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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();
       }