RFR: 8356152: String.concat can throw StringIndexOutOfBoundsException [v4]
Raffaello Giulietti
rgiulietti at openjdk.org
Mon May 5 17:49:47 UTC 2025
On Mon, 5 May 2025 17:11:46 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:
>> test/jdk/java/lang/String/concat/HugeConcatTest.java line 38:
>>
>>> 36: import static org.junit.Assert.assertThrows;
>>> 37:
>>> 38: public class HugeConcatTest {
>>
>> I've tried to execute the test with reverting changes in `StringConcatHelper` - it doesn't fail.
>> Added logging and actually OOM happened due to heap size:
>>
>> Reall got OOM: java.lang.OutOfMemoryError: Overflow: String length out of range
>> Reall got OOM: java.lang.OutOfMemoryError: Overflow: String length out of range
>> Reall got OOM: java.lang.OutOfMemoryError: Java heap space
>> Reall got OOM: java.lang.OutOfMemoryError: Java heap space
>> Reall got OOM: java.lang.OutOfMemoryError: Java heap space
>> Reall got OOM: java.lang.OutOfMemoryError: Java heap space
>> Reall got OOM: java.lang.OutOfMemoryError: Overflow: String length out of range
>> Reall got OOM: java.lang.OutOfMemoryError: Overflow: String length out of range
>> ----------System.err:(13/854)----------
>> STARTED HugeConcatTest::testConcat_UTF16_UTF16 'testConcat_UTF16_UTF16()'
>> SUCCESSFUL HugeConcatTest::testConcat_UTF16_UTF16 'testConcat_UTF16_UTF16()' [9ms]
>> STARTED HugeConcatTest::testConcat_Latin1_UTF16 'testConcat_Latin1_UTF16()'
>> SUCCESSFUL HugeConcatTest::testConcat_Latin1_UTF16 'testConcat_Latin1_UTF16()' [657ms]
>> STARTED HugeConcatTest::testConcat_UTF16_Latin1 'testConcat_UTF16_Latin1()'
>> SUCCESSFUL HugeConcatTest::testConcat_UTF16_Latin1 'testConcat_UTF16_Latin1()' [52ms]
>> STARTED HugeConcatTest::testConcat_Latin1_Latin1 'testConcat_Latin1_Latin1()'
>> SUCCESSFUL HugeConcatTest::testConcat_Latin1_Latin1 'testConcat_Latin1_Latin1()' [1ms]
>>
>>
>> I think we should validate error message too. Not only fact that it was thrown.
>
> _Really_ fails with Xmx7G
Yes, the required heap size was not enough for the reverted variant to throw a non-OOME exception/error.
Just out of curiosity, is JDK-8356152 a real-world issue you stumbled upon, or did you encounter it during some testing of yours?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25038#discussion_r2073899613
More information about the core-libs-dev
mailing list