RFR: 8339725: Concurrent GC crashed due to GetMethodDeclaringClass [v2]

Coleen Phillimore coleenp at openjdk.org
Mon Sep 9 14:47:10 UTC 2024


On Mon, 9 Sep 2024 06:04:36 GMT, Liang Mao <lmao at openjdk.org> wrote:

>> Hi,
>> 
>> It's a fix for 8339725. I think getting the oop from Klass::java_mirror() should use a ON_PHANTOM_OOP_REF decorator here which could make sure the oop would be kept alive in concurrent marking and return nullptr while in concurrent reference processing and unloading.
>> 
>> test/hotspot/jtreg/runtime and gc are clean.
>> 
>> Thanks,
>> Liang
>
> Liang Mao has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix build error in windows/mac

I think this is wrong.  We want 'resolve' to read the oop and tell the GC that this oop should be alive.  If GetMethodDeclaringClass is crashing, make sure the holder is alive before the iteration could safepoint.

This code does keep it in a Handle, so that should be sufficient.

    jclass
    JvmtiEnvBase::get_jni_class_non_null(Klass* k) {
      assert(k != nullptr, "k != null");
      Thread *thread = Thread::current();
      return (jclass)jni_reference(Handle(thread, k->java_mirror()));
    }

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

Changes requested by coleenp (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/20907#pullrequestreview-2290148202


More information about the hotspot-dev mailing list