RFR: 8256726: Zero: print proper message in ArrayIndexOutOfBoundException
David Holmes
david.holmes at oracle.com
Fri Nov 27 09:14:50 UTC 2020
On 27/11/2020 7:10 pm, Aleksey Shipilev wrote:
> On Fri, 27 Nov 2020 09:03:58 GMT, Severin Gehwolf <sgehwolf at openjdk.org> wrote:
>
>>> Manifests on tier1 test:
>>>
>>> $ CONF=linux-x86_64-zero-fastdebug make run-test TEST=runtime/exceptionMsgs/ArrayIndexOutOfBoundsException/
>>> test ArrayIndexOutOfBoundsExceptionTest.testAIOOBMessages(): failure
>>> java.lang.AssertionError: expected [Index -5 out of bounds for length 0] but found [-5]
>>>
>>> Fix does similar thing to what `Runtime1::throw_range_check_exception` does, but using a safer `jio_snprintf`.
>>>
>>> Additional testing:
>>> - [x] AIOBB tests on Linux x86_64 Zero fastdebug
>>
>> src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp line 1504:
>>
>>> 1502: arrayOop arrObj = (arrayOop)STACK_OBJECT(arrayOff); \
>>> 1503: jint index = STACK_INT(arrayOff + 1); \
>>> 1504: char message[2 * jintAsStringSize + 35]; \
>>
>> What's this magic `35` here? `strlen("Index A out of bounds for length B") + 1 == 35`. Isn't this counting the integers twice?
>>
>> Consider adding a comment.
>
> Seems OK to overestimate a bit. That's what `Runtime1::throw_range_check_exception` does in C1, so I have not challenged it:
> https://github.com/openjdk/jdk/blob/2f06893a29fba3b40cc1cf03095b75b217d1bb93/src/hotspot/share/c1/c1_Runtime1.cpp#L668-L671
>
> It should count the integers twice, because there are two integers in the string.
They are "counted twice" in the sense that the 35 allows for two single
digit integers, but you separately allowed for arbitrary valued integers.
Cheers,
David
> -------------
>
> PR: https://git.openjdk.java.net/jdk/pull/1341
>
More information about the hotspot-runtime-dev
mailing list