ADDITIONAL SYSTEM INFORMATION :
Windows Server and Windows 11 / Desktop (both 64 bit) running Java 21 (and above, but not below) using the JVMs from Oracle (and other vendors, like amazon or adoptium).
A DESCRIPTION OF THE PROBLEM :
JVM crashes (after some warm-up phase) running Java 21 (and above, but not below) using the JVMs from Oracle (and other vendors, like amazon or adoptium).
The code to reproduce the issue is non-shareable / closed-source (sorry for that), but it could quite stably reproduce the issue locally (server and desktop – using windows 64 bit).
The application is a webapp using tomcat application-server and the triggering “test” is single-threaded and is doing some SQL changes (including string creation for the prepared statements) for “translations” in a loop.
After a while (some hundred iterations running stable) it looks like hitting a C2 (hotspot) issue, because GraalVM (using a different C2) is working and non-working versions (like 21.0.4) are working (quite slow), if C2 is disabled (using -XX:TieredStopAtLevel=3).
Another important thing to know is, that the issue is aligned to the disabled or not available “compressed oops” mode (System.getProperty("java.vm.compressedOopsMode") returns null).
This enables a workaround, to configure a max heap size 32256m (and below – for Java21) or using -XX:ObjectAlignmentInBytes=16/32… (to use more memory with “compressed oops”).
Thank you very much for checking and hopefully fixing the issue.
All you hard work is very much appreciated!
Btw. this is my first reported crash, so the JVM normally runs perfect.
In addition, I know, that the C2 optimizations are quite hard to maintain (a reason for the new GraalVM).
REGRESSION : Last worked in version 11.0.24
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The code to reproduce the issue is non-shareable / closed source (sorry for that), but it could quite stably reproduce the issue locally (server and desktop – using windows 64 bit).
The application is a webapp using tomcat application-server and the triggering “test” is single-threaded and is doing some SQL changes (including string creation for the prepared statements) for “translations” in a loop.
ACTUAL -
Crashes (see “hs_err_pid files”) and “strange” exceptions (after a warm-up phase and right before the crash, where magically something got null), like:
java.lang.StringIndexOutOfBoundsException: Range [67, 67 + 0) out of bounds for length 48
at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55) ~[?:?]
at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52) ~[?:?]
at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213) ~[?:?]
at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210) ~[?:?]
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98) ~[?:?]
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromIndexSize(Preconditions.java:118) ~[?:?]
at java.base/jdk.internal.util.Preconditions.checkFromIndexSize(Preconditions.java:397) ~[?:?]
at java.base/java.lang.String.checkBoundsOffCount(String.java:4853) ~[?:?]
at java.base/java.lang.StringUTF16.checkBoundsOffCount(StringUTF16.java:1625) ~[?:?]
at java.base/java.lang.StringUTF16.inflate(StringUTF16.java:1459) ~[?:?]
at java.base/java.lang.StringLatin1.inflate(StringLatin1.java:771) ~[?:?]
at java.base/java.lang.String.getBytes(String.java:4728) ~[?:?]
at java.base/java.lang.StringConcatHelper.prepend(StringConcatHelper.java:324) ~[?:?]
at java.base/java.lang.StringConcatHelper.prepend(StringConcatHelper.java:343) ~[?:?]
java.lang.NullPointerException: Cannot invoke "Object.toString()" because "value" is null
at java.base/java.lang.StringConcatHelper.stringOf(StringConcatHelper.java:467) ~[?:?]
at com.webfair.domain.dynamicresources.TranslationItem.toString(TranslationItem.java:77) ~[launchnet-backend.jar:?]
at java.base/java.lang.String.valueOf(String.java:4465) ~[?:?]
at java.base/java.lang.StringBuilder.append(StringBuilder.java:173) ~[?:?]
at java.base/java.util.AbstractCollection.toString(AbstractCollection.java:459) ~[?:?]
at java.base/java.lang.StringConcatHelper.stringOf(StringConcatHelper.java:467) ~[?:?]
at java.base/java.lang.StringConcatHelper.simpleConcat(StringConcatHelper.java:422) ~[?:?]
The TranslationItem.toString method is a simple autogenerated toString method using fixed strings and basic (int, String, Integer) properties.
java.lang.NullPointerException: Cannot read the array length because "this.value" is null
at java.base/java.lang.String.length(String.java:1519) ~[?:?]
at java.base/java.lang.StringConcatHelper.mix(StringConcatHelper.java:123) ~[?:?]
at com.webfair.domain.dynamicresources.TranslationItem.toString(TranslationItem.java:77) ~[launchnet-backend.jar:?]
at java.base/java.lang.String.valueOf(String.java:4465) ~[?:?]
at java.base/java.lang.StringBuilder.append(StringBuilder.java:173) ~[?:?]
at java.base/java.util.AbstractCollection.toString(AbstractCollection.java:459) ~[?:?]
at java.base/java.lang.StringConcatHelper.stringOf(StringConcatHelper.java:467) ~[?:?]
at java.base/java.lang.StringConcatHelper.simpleConcat(StringConcatHelper.java:422) ~[?:?]
All were using Java 21.0.4 (to find the lines in the source correctly), but there are similar issues in other non-working versions too.
---------- BEGIN SOURCE ----------
Sorry code to trigger the issue is non-shareable / closed source, so sharing the “test case” code (isolated) would make no sense.
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
- Use „older“ Java version < 21
- Use GraalVM (even with Java21)
- Disable C2 (using -XX:TieredStopAtLevel=3) even if it’s then quite slow (and may not acceptable)
- Keep “compressed oops” mode active (System.getProperty("java.vm.compressedOopsMode") returns not null)
FREQUENCY : often