RFR: 8312401: SymbolTable::do_add_if_needed hang when requesting length exceeds max_symbol_length [v2]

Coleen Phillimore coleenp at openjdk.org
Mon Jul 24 13:08:55 UTC 2023


On Sat, 22 Jul 2023 00:39:19 GMT, Jiangli Zhou <jiangli at openjdk.org> wrote:

>> Please review the simple fix to resolve infinite loop in SymbolTable::do_add_if_needed caused by extra long symbol string that exceeds Symbol::max_length(). See JDK-8312401 for details.
>> 
>> The jtreg test is converted from a test case constructed by @cushon.
>
> Jiangli Zhou has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update according to David Holmes' comments.
>   - In java_lang_String::as_symbol and java_lang_String::as_symbol_or_null, check input string length and truncate to max symbol length if exceeding.
>   - Change java_lang_Throwable::create_initialization_error to avoid using Symbol for message.

I think just the javaClasses.cpp and the test should be enough to fix this bug.  Thank you for fixing it.

src/hotspot/share/classfile/javaClasses.cpp line 581:

> 579:     length = Symbol::max_length();
> 580:   }
> 581: 

There's other code that checks that Symbol length < max length.  Ignoring seems bad here.  It should just truncate the exception symbol below.

src/hotspot/share/classfile/javaClasses.cpp line 2782:

> 2780:   if (detailed_message != nullptr) {
> 2781:     message = java_lang_String::as_utf8_string(detailed_message);
> 2782:   }

It looks like you did remove converting the message to a Symbol here, so are there other places where long symbol names come through this code?  We should catch them at their sources.

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

PR Review: https://git.openjdk.org/jdk/pull/14938#pullrequestreview-1543432327
PR Review Comment: https://git.openjdk.org/jdk/pull/14938#discussion_r1272228190
PR Review Comment: https://git.openjdk.org/jdk/pull/14938#discussion_r1272235954


More information about the hotspot-runtime-dev mailing list