RFR: 8356152: String.concat can throw StringIndexOutOfBoundsException [v4]
Andrey Turbanov
aturbanov at openjdk.org
Mon May 5 17:14:47 UTC 2025
On Mon, 5 May 2025 14:38:05 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
>> A fix to throw `OutOfMemoryError`, as done in releases ≤ 23.
>
> Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision:
>
> Added language concat + to test.
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.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25038#discussion_r2073833500
More information about the core-libs-dev
mailing list