RFR: 8365526: Crash with null Symbol passed to SystemDictionary::resolve_or_null
Tom Rodriguez
never at openjdk.org
Fri Nov 21 17:14:47 UTC 2025
On Thu, 20 Nov 2025 17:00:04 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:
> The vm was crashing because the constant pool couldn't find the resolution error in the ResolutionErrorEntry error field.
>
> There are two uses of ResolutionErrorEntry in the ResolutionErrorTable. The key to this table is {ConstantPool, cp-index}. In this crash, multiple threads were racing to record nest_host_errors in the case where resolution failed. In this case, there was already a ResolutionErrorEntry in the table for the constant pool resolution failure. In the 'if' case of add_nest_host_error we check to see if there's already a nest_host_error assuming it's the same error, then the 'else' case was unconditionally adding a ResolutionErrorEntry with just the nest host message. Calling HashTable::put() with this entry with just the nest host message, was overwriting the entry with the constant pool resolution error, ie. the other fields. The crash happened in ConstantPool::throw_resolution_error() because the error field was overwritten (and leaked too).
>
> Add a null check before calling ResolutionErrorEntry add entry. Also added an assert that we only add a resolution error for nest host errors in the case of success since in the case of failure there will always already be a ResolutionErrorEntry for the failing constant pool and cp index and we don't want to overwrite that again.
>
> Tested with submitted reproducer and tier1-4.
Thanks for tracking this down! Looks good.
src/hotspot/share/classfile/systemDictionary.cpp line 1877:
> 1875: // resolution succeeded but there's an error in this nest host.
> 1876: assert(pool->resolved_klass_at(which) != nullptr, "klass is should be resolved if there is no entry");
> 1877: ResolutionErrorTable::add_entry(pool, which, message);
I might be inclined to swap the cases.
if (entry == nullptr) {
...
} else if (entry->nest_host_error() == nullptr) {
...
}
Is there ever a situation where replacing an entry in ResolutionErrorTable is correct? Maybe there should be a check for that somewhere?
-------------
Marked as reviewed by never (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/28438#pullrequestreview-3493677260
PR Review Comment: https://git.openjdk.org/jdk/pull/28438#discussion_r2550445406
More information about the hotspot-runtime-dev
mailing list