RFR: 8374448: SIGSEGV in ConstantPool::print_value_on with -XX:CompileCommand=print

David Holmes dholmes at openjdk.org
Tue Feb 10 01:23:38 UTC 2026


On Fri, 6 Feb 2026 16:00:55 GMT, Kerem Kat <krk at openjdk.org> wrote:

> `BSMAttributeEntries::is_empty()` used AND, so `!is_empty()` was true when only one of `_offsets`/`_bootstrap_methods` was non-null. Callers then dereferenced the null pointer.
> 
> Changed to OR so `!is_empty()` guarantees both are non-null. Added asserts at the two assignment sites to check for consistency.
> 
> Please note that I could not reproduce this in fastdebug or slowdebug builds on x86_64 Linux.

AFAICS the only way this failure can happen (which explains why it doesn't reproduce) is we are concurrently trying to print an entry (`bsm_entries()`) which is in the process of being updated (via `start_extension()`) and so we temporarily see an inconsistent state.  We could accommodate that with the suggested change to `is_empty` but I would want add a comment explaining why we give the appearance that the two fields could be inconsistently null. But looking at the code that fails:

  if (!bsm_entries().is_empty())  st->print("/BSMs[%d]", bsm_entries().bootstrap_methods()->length());

it seems to me that a better way to avoid this potential race is to use:

  if (!bsm_entries().is_empty())  st->print("/BSMs[%d]", bsm_entries().array_length());

because `array_length` handles the case of `_bootstrap_methods` being null.

src/hotspot/share/oops/constantPool.cpp line 2386:

> 2384:   _offsets = new_offsets;
> 2385:   _bootstrap_methods = new_array;
> 2386:   assert((_offsets == nullptr) == (_bootstrap_methods == nullptr), "inconsistent state");

This is a pointless assertion - it can only fail if `MetadataFactory::new_array` returns null but we fail to return via the CHECK macro.

src/hotspot/share/oops/constantPool.cpp line 2425:

> 2423:   _offsets = new_offsets;
> 2424:   _bootstrap_methods = new_array;
> 2425:   assert((_offsets == nullptr) == (_bootstrap_methods == nullptr), "inconsistent state");

This is a pointless assertion - it can only fail if `MetadataFactory::new_array` returns null but we fail to return via the CHECK macro.

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

Changes requested by dholmes (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/29611#pullrequestreview-3776169244
PR Review Comment: https://git.openjdk.org/jdk/pull/29611#discussion_r2785242368
PR Review Comment: https://git.openjdk.org/jdk/pull/29611#discussion_r2785242834


More information about the hotspot-dev mailing list