RFR: 8339725: Concurrent GC crashed due to GetMethodDeclaringClass [v5]
Liang Mao
lmao at openjdk.org
Wed Sep 11 07:19:05 UTC 2024
On Wed, 11 Sep 2024 07:01:27 GMT, David Holmes <dholmes at openjdk.org> wrote:
> I think you are missing my point:
>
> ```
> Klass* k = method->method_holder();
> // Why can't k already be not-alive here?
> Handle holder(Thread::current(), k->klass_holder()); // keep the klass alive
> ```
>
> > In next GC, the class could be unloaded if the JNI handle with class is released.
>
> Again this misses my point. If calling `k->klass_holder()` keeps `k` alive, what do we need to do to undo that? I assume there must be some kind of reference count in relation to this. ??
We don't need to undo. The holder is a Java heap oop with WeakHandle connected to CLD. If we keep it alive, the oop will be made tri-color marking `GREY` and then be traced/marked. It would be dead in next GC cycle if no explicit reference or keeping alive again.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/20907#issuecomment-2342847237
More information about the hotspot-dev
mailing list