From 6123316c0dc0cc566f71b80e9290d77653408829 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 19 Nov 2025 23:09:58 -0500 Subject: [PATCH 1/2] 8365526: Crash with null Symbol passed to SystemDictionary::resolve_or_null --- src/hotspot/share/classfile/systemDictionary.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index 5c49a32b8d04d..11e5401cc892b 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -1870,7 +1870,10 @@ void SystemDictionary::add_nest_host_error(const constantPoolHandle& pool, // only reach here under the same error condition, so we can ignore the potential race with setting // the message. If we see it is already set then we can ignore it. entry->set_nest_host_error(message); - } else { + } else if (entry == nullptr) { + // Only add a new resolution error if one hasn't been found for this constant pool index. In this case, + // resolution succeeded but there's an error in this nest host. + assert(pool->resolved_klass_at(which) != nullptr, "klass is should be resolved if there is no entry"); ResolutionErrorTable::add_entry(pool, which, message); } } From 8e7be57dd9934c522122d2996ae670c0190adfc3 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Fri, 21 Nov 2025 13:53:28 -0500 Subject: [PATCH 2/2] Reorder if statement and add an assert. --- src/hotspot/share/classfile/resolutionErrors.cpp | 4 +++- src/hotspot/share/classfile/systemDictionary.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/hotspot/share/classfile/resolutionErrors.cpp b/src/hotspot/share/classfile/resolutionErrors.cpp index 25aa370d2571a..919fe0b6c2f22 100644 --- a/src/hotspot/share/classfile/resolutionErrors.cpp +++ b/src/hotspot/share/classfile/resolutionErrors.cpp @@ -85,7 +85,9 @@ void ResolutionErrorTable::add_entry(const constantPoolHandle& pool, int cp_inde ResolutionErrorKey key(pool(), cp_index); ResolutionErrorEntry *entry = new ResolutionErrorEntry(message); - _resolution_error_table->put(key, entry); + bool created = false; + _resolution_error_table->put_if_absent(key, entry, &created); + assert(created, "should be created not updated"); } // find entry in the table diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index 11e5401cc892b..fb4974c4a7f13 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -1864,17 +1864,17 @@ void SystemDictionary::add_nest_host_error(const constantPoolHandle& pool, { MutexLocker ml(Thread::current(), SystemDictionary_lock); ResolutionErrorEntry* entry = ResolutionErrorTable::find_entry(pool, which); - if (entry != nullptr && entry->nest_host_error() == nullptr) { + if (entry == nullptr) { + // Only add a new resolution error if one hasn't been found for this constant pool index. In this case, + // resolution succeeded but there's an error in this nest host. + assert(pool->resolved_klass_at(which) != nullptr, "klass is should be resolved if there is no entry"); + ResolutionErrorTable::add_entry(pool, which, message); + } else if (entry->nest_host_error() == nullptr) { // An existing entry means we had a true resolution failure (LinkageError) with our nest host, but we // still want to add the error message for the higher-level access checks to report. We should // only reach here under the same error condition, so we can ignore the potential race with setting // the message. If we see it is already set then we can ignore it. entry->set_nest_host_error(message); - } else if (entry == nullptr) { - // Only add a new resolution error if one hasn't been found for this constant pool index. In this case, - // resolution succeeded but there's an error in this nest host. - assert(pool->resolved_klass_at(which) != nullptr, "klass is should be resolved if there is no entry"); - ResolutionErrorTable::add_entry(pool, which, message); } } }