RFR: 8312401: SymbolTable::do_add_if_needed hang when requesting length exceeds max_symbol_length
Jiangli Zhou
jiangli at openjdk.org
Thu Jul 20 20:13:41 UTC 2023
On Thu, 20 Jul 2023 05:03:44 GMT, David Holmes <dholmes at openjdk.org> wrote:
> I'm not sure silently ignoring this by returning null is the right thing to do. Shouldn't we just truncate the message in this case?
>
> Or are we even doing the wrong thing by returning as a Symbol in the first place? By doing so we seem to impose an artificial VM limit on the exception message length.
Max Symbol length is 64K. Exception message is bound to String length, 0x7FFFFFFF (2147483647). I did some history search. Using Symbol for throwable message was initially done for ResolutionErrorTable::add_entry in JDK 8. That's been a long time. No issue has been surfaced for ResolutionError part.
Currently java_lang_Throwable::detail_message can be called by the [following](https://github.com/search?q=repo%3Aopenjdk%2Fjdk%20java_lang_Throwable%3A%3Adetail_message%20&type=code):
- java_lang_Throwable::create_initialization_error
- Exceptions::log_exception
- ConstantPoolCache::save_and_throw_indy_exc
- exception_message
- add_resolution_error
No sure truncating the message would be better than returning a nullptr when the length exceeds max symbol length for above cases. Both behaviors are undefined by spec. Since these cases are VM internal implementation details only, maybe either truncating or nullptr is fine. Please let me know your preference.
I checked all callers and they can tolerate null message. For java_lang_Throwable::create_initialization_error, when java_lang_Throwable::detail_message returns nullptr, it fills the new ExceptionInInitializerError with the thread and frame information.
I considered changing to use `char *` for the message in java_lang_Throwable::create_initialization_error (https://github.com/openjdk/jdk/pull/14938/commits/e2223f0613d53e89e11af587dc3d41a25ffd6849). But we need to handle all other callers as well. Exceptions::log_exception can use `char *` also. The other callers still require Symbol.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14938#issuecomment-1644534913
More information about the hotspot-runtime-dev
mailing list