On Tue, 4 Feb 2025 00:59:57 GMT, Shaojin Wen <[email protected]> wrote:
>> The following code can reproduce the problem, writing out of bounds causes
>> JVM Crash
>>
>>
>> StringBuilder buf = new StringBuilder();
>> buf.append('δΈ');
>>
>> final CountDownLatch latch = new CountDownLatch(10);
>> Runnable r = () -> {
>> for (int i = 0; i < 10000; i++) {
>> buf.setLength(0);
>> buf.trimToSize();
>> buf.append(123456789);
>> }
>> latch.countDown();
>> };
>> Thread[] threads = new Thread[10];
>> for (int i = 0; i < threads.length; i++) {
>> threads[i] = new Thread(r);
>> }
>> for (Thread t : threads) {
>> t.start();
>> }
>> latch.await();
>> }
>>
>>
>> This problem can be avoided by using the value of ensureCapacityInternal
>> directly.
>
> Shaojin Wen has updated the pull request incrementally with one additional
> commit since the last revision:
>
> skip coder change
I am confused about the description. How exactly is the JVM crashed? Does the
interpreter or compiled code crash?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23427#issuecomment-2633788477