RFR: 8369021: A crash in ConstantPool::klass_at_impl [v2]

David Holmes dholmes at openjdk.org
Fri Oct 10 05:41:11 UTC 2025


On Thu, 9 Oct 2025 16:49:49 GMT, Jan Kratochvil <jkratochvil at openjdk.org> wrote:

>> https://bugs.openjdk.org/browse/JDK-8369021
>
> Jan Kratochvil has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
> 
>  - Merge branch 'master' into linkclass
>  - Make an alternative fix in compute_enclosing_class
>  - Revert "8369021: A crash in ConstantPool::klass_at_impl"
>    
>    This reverts commit 026fcb1b21729e41524169c7f78855e8794ddae2.
>  - 8369021: A crash in ConstantPool::klass_at_impl

I am still trying to piece together the actual problem here. 
- We are calling `GetDeclaringClass` on a given class `k`.
- We have found that `k` lists `outer_k` as its enclosing class.
- We are checking if `outer_k` lists `k` as an inner class via `Reflection::check_for_inner_class.
- We are looking up `outer_k->constants->klass_at(x)` where `x` could be the inner-class index or the outher-class index (can't tell which from the bug report)
- `klass_at_impl` does ` Handle loader (THREAD, this_cp->pool_holder()->class_loader());`, which is the same as `outer_k->class_loader()`
- `class_loader()` does `return class_loader_data()->class_loader()`
- we crash because `class_loader_data()` is null.

We normally set the `class_loader_data` during class file parsing, in `fill_instance_klass` which is done with `create_instance_klass`. So there is no way it should be null. And it not being null is not connected with the class being linked.

So there is a big piece of this puzzle missing for me.

src/hotspot/share/oops/instanceKlass.cpp line 3332:

> 3330:   if (nullptr == outer_klass) return nullptr;
> 3331: 
> 3332:   // Wait until also outer_klass gets fully loaded.

How are you "waiting"?

src/hotspot/share/oops/instanceKlass.cpp line 3333:

> 3331: 
> 3332:   // Wait until also outer_klass gets fully loaded.
> 3333:   InstanceKlass* pool_holder = outer_klass->constants()->pool_holder();

This should just set `pool_holder == outer_klass`. When we parse a class we do:

 _cp->set_pool_holder(this_klass);
this_klass->set_constants(_cp);

so `klass->constants()->pool_holder() == klass`. ??

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

PR Review: https://git.openjdk.org/jdk/pull/27595#pullrequestreview-3321335573
PR Review Comment: https://git.openjdk.org/jdk/pull/27595#discussion_r2418493625
PR Review Comment: https://git.openjdk.org/jdk/pull/27595#discussion_r2418508887


More information about the hotspot-dev mailing list