8315890: Attempts to load from nullptr in instanceKlass.cpp and unsafe.cpp

Reviewed-by: coleenp, ccheung, dholmes
This commit is contained in:
Matias Saavedra Silva 2023-11-02 14:30:41 +00:00
parent cb20a3e7a6
commit 7a7b1e5a92
2 changed files with 4 additions and 2 deletions

View File

@ -1133,6 +1133,7 @@ class ArchiveBuilder::CDSMapLogger : AllStatic {
// The address of _source_obj at runtime
oop requested_obj = ArchiveHeapWriter::source_obj_to_requested_obj(_source_obj);
// The address of this field in the requested space
assert(requested_obj != nullptr, "Attempting to load field from null oop");
address requested_field_addr = cast_from_oop<address>(requested_obj) + fd->offset();
fd->print_on(_st);

View File

@ -2503,10 +2503,11 @@ void InstanceKlass::clean_implementors_list() {
assert (ClassUnloading, "only called for ClassUnloading");
for (;;) {
// Use load_acquire due to competing with inserts
InstanceKlass* impl = Atomic::load_acquire(adr_implementor());
InstanceKlass* volatile* iklass = adr_implementor();
assert(iklass != nullptr, "Klass must not be null");
InstanceKlass* impl = Atomic::load_acquire(iklass);
if (impl != nullptr && !impl->is_loader_alive()) {
// null this field, might be an unloaded instance klass or null
InstanceKlass* volatile* iklass = adr_implementor();
if (Atomic::cmpxchg(iklass, impl, (InstanceKlass*)nullptr) == impl) {
// Successfully unlinking implementor.
if (log_is_enabled(Trace, class, unload)) {