8223391: Unsynchronized iteration of ClassLoaderDataGraph

Lock in G1 before clear_claimed_marks

Reviewed-by: hseigel, lfoltan, tschatzl
This commit is contained in:
Coleen Phillimore 2019-05-08 06:40:45 -04:00
parent 40fddae1dc
commit dc2c1d3ba8
2 changed files with 2 additions and 0 deletions

View File

@ -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();
}

View File

@ -268,6 +268,7 @@ void G1ConcurrentMarkThread::run_service() {
{
G1ConcPhase p(G1ConcurrentPhase::CLEAR_CLAIMED_MARKS, this);
MutexLocker ml(ClassLoaderDataGraph_lock);
ClassLoaderDataGraph::clear_claimed_marks();
}