RFR: 8352092: -XX:AOTMode=record crashes with InstanceKlass in allocated state

Coleen Phillimore coleenp at openjdk.org
Wed Mar 26 11:52:07 UTC 2025


On Sat, 22 Mar 2025 04:39:40 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> Please review this small fix for a crash that can be caused only with JNI `DefineClass()` calls, which can leave a class in the `allocated` state inside a `ClassLoaderData` when the class is in a prohibited package such as `java/foo`.
> 
> The bug was found when running the JCK with an AOT cache. I tried to write a jtreg regression test but it's not possible to use pure Java code to reproduce this condition -- attempts by Java code to define classes in a prohibited package will be blocked from entering the ClassFileParser.

src/hotspot/share/cds/metaspaceShared.cpp line 759:

> 757:     for (int i = 0; i < collect_cld.nof_cld(); i++) {
> 758:       ClassLoaderData* cld = collect_cld.cld_at(i);
> 759:       for (Klass* klass = cld->klasses(); klass != nullptr; klass = klass->next_link()) {

Why doesn't this call loaded_classes_do() ?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24172#discussion_r2013968090


More information about the hotspot-runtime-dev mailing list