RFR: 8338888: SystemDictionary::class_name_symbol has incorrect length check

David Holmes dholmes at openjdk.org
Tue Aug 27 08:03:05 UTC 2024


On Tue, 27 Aug 2024 06:18:29 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> The name length check was incorrectly truncating the length to an int, which is wrong if the name is > `INT_MAX`. Added a test for this case to the existing test cases and fixed an issue with the call to `Exceptions::fthrow` that can hit the `INT_MAX` limitations of `os::vsnprintf` (this is the first in a serious of fixes that will mainly be done under [JDK-8328882](https://bugs.openjdk.org/browse/JDK-8328882) or subtasks thereof).
>> 
>> Testing:
>>  - updated test
>>  - tiers 1-3 (sanity)
>> 
>> Thanks
>
> test/hotspot/jtreg/runtime/exceptionMsgs/NoClassDefFoundError/libNoClassDefFoundErrorTest.c line 50:
> 
>> 48: 
>> 49: static char* giant_string() {
>> 50:     size_t len = ((size_t)INT_MAX) + 3;
> 
> I don't think we need to allocate and touch 2GB for this test. Lets just allocate 64K + x, that should hit the Symbol name limit as well.

We already test that case, this is explicitly trying to test the INT_MAX issue where we would crash prior to this fix.

> test/hotspot/jtreg/runtime/exceptionMsgs/NoClassDefFoundError/libNoClassDefFoundErrorTest.c line 53:
> 
>> 51:     char* c_name = malloc(len * sizeof(char));
>> 52:     if (c_name != NULL) {
>> 53:         memset(c_name, 0x59595959, len - 1); // YYYY...
> 
> nit, `59` should be enough

?? you mean just 0x59? That would be zero extended to 0x00000059, which would not have the desired affect.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20709#discussion_r1732339022
PR Review Comment: https://git.openjdk.org/jdk/pull/20709#discussion_r1732337194


More information about the hotspot-runtime-dev mailing list