--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp Thu Jul 25 12:20:04 2019 +0530
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp Mon Jul 22 16:32:58 2019 -0400
@@ -1593,12 +1593,19 @@
void work(uint worker_id) {
ShenandoahEvacOOMScope oom;
- ShenandoahEvacuateUpdateRootsClosure cl;
- CLDToOopClosure clds(&cl, ClassLoaderData::_claim_strong);
-
- _jni_roots.oops_do<ShenandoahEvacuateUpdateRootsClosure>(&cl);
- _cld_roots.cld_do(&clds);
- _weak_roots.oops_do<ShenandoahEvacuateUpdateRootsClosure>(&cl);
+ {
+ // jni_roots and weak_roots are OopStorage backed roots, concurrent iteration
+ // may race against OopStorage::release() calls.
+ ShenandoahEvacUpdateOopStorageRootsClosure cl;
+ _jni_roots.oops_do<ShenandoahEvacUpdateOopStorageRootsClosure>(&cl);
+ _weak_roots.oops_do<ShenandoahEvacUpdateOopStorageRootsClosure>(&cl);
+ }
+
+ {
+ ShenandoahEvacuateUpdateRootsClosure cl;
+ CLDToOopClosure clds(&cl, ClassLoaderData::_claim_strong);
+ _cld_roots.cld_do(&clds);
+ }
}
};