RFR: 8278125: Some preallocated OOMEs are missing stack trace [v2]
Coleen Phillimore
coleenp at openjdk.java.net
Mon Dec 20 23:19:46 UTC 2021
On Thu, 16 Dec 2021 04:41:03 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> Ok, I see how this isn't right, but I still don't like the strcmp. Can the string be interned and checked for equality? Otherwise you also need a ResourceMark here.
>
> We are comparing a `char*` and a Java String (the message from the Exception oop), so we either convert the Java String to a `char*` and compare them with `strcmp` as shown; or we turn the incoming `char*` into a Java String and then use `java_lang_String::equals`. The latter is an expensive operation and more importantly creating the String requires an allocation when we are trying to throw an OutOfMemoryError! So I don't see a reasonable alternative to the `strcmp`.
This would still need a ResourceMark, since java_lang_String::as_utf8_string() allocates into a resource allocated array.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6672
More information about the hotspot-runtime-dev
mailing list