From dc2c1d3ba8428ddbd44c61de43dec41af9f2d0a4 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 8 May 2019 06:40:45 -0400 Subject: [PATCH] 8223391: Unsynchronized iteration of ClassLoaderDataGraph Lock in G1 before clear_claimed_marks Reviewed-by: hseigel, lfoltan, tschatzl --- src/hotspot/share/classfile/classLoaderDataGraph.cpp | 1 + src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/hotspot/share/classfile/classLoaderDataGraph.cpp b/src/hotspot/share/classfile/classLoaderDataGraph.cpp index 8575e987156..14df71f6e25 100644 --- a/src/hotspot/share/classfile/classLoaderDataGraph.cpp +++ b/src/hotspot/share/classfile/classLoaderDataGraph.cpp @@ -48,6 +48,7 @@ volatile size_t ClassLoaderDataGraph::_num_array_classes = 0; 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(); } diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp index be172361b8a..2d460b4fb90 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp @@ -268,6 +268,7 @@ void G1ConcurrentMarkThread::run_service() { { G1ConcPhase p(G1ConcurrentPhase::CLEAR_CLAIMED_MARKS, this); + MutexLocker ml(ClassLoaderDataGraph_lock); ClassLoaderDataGraph::clear_claimed_marks(); }