[9] RFR(XS): 8076625: IndexOutOfBoundsException in HeapByteBufferTest.java

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Thu Apr 9 14:33:48 UTC 2015


Looks good.

Best regards,
Vladimir Ivanov

On 4/9/15 3:10 PM, Tobias Hartmann wrote:
> Hi,
>
> please review the following patch.
>
> https://bugs.openjdk.java.net/browse/JDK-8076625
> http://cr.openjdk.java.net/~thartmann/8076625/webrev.00/
>
> Problem:
> A random offset to access in a byte array is computed by
>
>    int randomOffset(SplittableRandom r, MyByteBuffer buf, int size) {
>      return abs(r.nextInt()) % (buf.capacity() - size);
>    }
>
> The call to r.nextInt() may return Integer.MIN_VALUE (-2147483648) and the corresponding absolute value (+2147483648) does not fit into an int and will overflow back to -2147483648. As a result the returned offset is negative.
>
> Solution:
> Use nextInt(int n) to set the limit of the random value.
>
> Testing:
> Failing testcase and JPRT.
>
> Thanks,
> Tobias
>


More information about the hotspot-compiler-dev mailing list