8223391: Unsynchronized iteration of ClassLoaderDataGraph
Summary: lock in G1 before clear_claimed_marks
Reviewed-by: hseigel, lfoltan, tschatzl
--- 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();
}