RFR: 8364360: Defining hidden class with no room in constant pool crashes the VM [v6]

Matias Saavedra Silva matsaave at openjdk.org
Fri Oct 31 18:58:05 UTC 2025


On Fri, 31 Oct 2025 18:21:21 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> Check for constant pool index overflow and throw ClassFormatError instead of crashing.
>> Tested with tier1-4.
>
> Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Simplify the test.

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.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27964#discussion_r2482403035


More information about the hotspot-runtime-dev mailing list