RFR: 8344026: Ubsan: prevent potential integer overflow in c1_LIRGenerator_<arch>.cpp file [v8]

Emanuel Peter epeter at openjdk.org
Wed Dec 4 08:34:45 UTC 2024


On Wed, 4 Dec 2024 08:30:19 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> Amit Kumar has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   unsigned int -> juint
>
> src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp line 281:
> 
>> 279: bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, jint c, LIR_Opr result, LIR_Opr tmp) {
>> 280:   juint u_value = (juint)c;
>> 281:   if (is_power_of_2(u_value - 1)) {
> 
> What happens if this underflows? Is this not undefined behaviour? Could we use `java_add`?

And do you have some sort of tests for this, to make sure we check with all possible `c` values?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22144#discussion_r1868953085


More information about the hotspot-compiler-dev mailing list