RFR: 8364360: Defining hidden class with no room in constant pool crashes the VM [v6]
Coleen Phillimore
coleenp at openjdk.org
Fri Oct 31 19:33:04 UTC 2025
On Fri, 31 Oct 2025 19:12:50 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:
>> src/hotspot/share/classfile/classFileParser.cpp line 5529:
>>
>>> 5527: // Check for overflow. cp_size is a u2.
>>> 5528: assert(sizeof(cp_size) == sizeof(u2), "this overflow test depends on this");
>>> 5529: guarantee_property(cp_size > _orig_cp_size, "Overflow in constant pool size for hidden class %s", CHECK);
>>
>> Isn't this technically UB behavior? It isn't guaranteed that a u2 will overflow to a low value. It might be safer have cp_size be an int and then guarantee that cp_size < 65535.
>
> Doing a cast to u4 and an overflow check might be the best thing. Then I won't need the assert.
I made this change and reran the VM jck tests.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27964#discussion_r2482474917
More information about the hotspot-runtime-dev
mailing list