RFR: 8352092: -XX:AOTMode=record crashes with InstanceKlass in allocated state
Ioi Lam
iklam at openjdk.org
Thu Mar 27 03:54:13 UTC 2025
On Wed, 26 Mar 2025 11:49:09 GMT, Coleen Phillimore <coleenp 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() ?
I update the PR to use `ClassLoaderDataGraph::loaded_classes_do_keepalive()`, so there's no need to explicitly check for `is_loaded()`.
Also, instead of holding onto the ClassLoader oops which has a side effect of keeping the classes alive, I am now holding onto the Java mirrors directly. This simplifies the code and hopefully makes it easier to understand.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24172#discussion_r2015558249
More information about the hotspot-runtime-dev
mailing list