RFR: 8344104: TestMergeStores fails with ArrayIndexOutOfBoundException

Dean Long dlong at openjdk.org
Wed Nov 13 23:40:55 UTC 2024


On Wed, 13 Nov 2024 15:34:07 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

> Test-bug: `RANDOM.nextInt()` would occasionally return a `min_int`. And sadly this overflows: `Math.abs(min_int) == min_int`. Wen we calculate it `% 100`, it still gives us a negative value, and we end up out of bounds. Fixed with a mask.

test/hotspot/jtreg/compiler/c2/TestMergeStores.java line 344:

> 342: 
> 343:             offset1 = Math.abs(RANDOM.nextInt() & 0x0fffffff) % 100;
> 344:             offset2 = Math.abs(RANDOM.nextInt() & 0x0fffffff) % 100;

Suggestion:

            offset1 = Integer.remainderUnsigned(RANDOM.nextInt(), 100);
            offset2 = Integer.remainderUnsigned(RANDOM.nextInt(), 100);

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/22080#discussion_r1841323146


More information about the hotspot-compiler-dev mailing list