8201556: Disallow reading oops in ClassLoaderData if unloading

Move class_loader oop to an OopHandle, and assert that holder is alive when getting class_loader.

Reviewed-by: kbarrett, adinn
This commit is contained in:
Coleen Phillimore 2018-04-18 18:43:04 -04:00
parent 702ac597ad
commit ddfd4c33c6
22 changed files with 121 additions and 47 deletions

View file

@ -51,8 +51,8 @@ template <WeakHandleType T>
void WeakHandle<T>::release() const {
// Only release if the pointer to the object has been created.
if (_obj != NULL) {
// Clear the WeakHandle. For class loader data race, the handle may not have
// been previously cleared by GC.
// Clear the WeakHandle. For race in creating ClassLoaderData, we can release this
// WeakHandle before it is cleared by GC.
RootAccess<ON_PHANTOM_OOP_REF>::oop_store(_obj, (oop)NULL);
get_storage()->release(_obj);
}