RFR: 8344026: Ubsan: prevent potential integer overflow in c1_LIRGenerator_<arch>.cpp file [v8]
Martin Doerr
mdoerr at openjdk.org
Wed Dec 4 09:37:42 UTC 2024
On Wed, 4 Dec 2024 08:31:50 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> 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?
> What happens if this underflows? Is this not undefined behaviour? Could we use `java_add`?
Unsigned subtraction is never undefined. "wrap around" behavior is used. Using `java_add` / `java_subtract` sounds like a good idea.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22144#discussion_r1869066654
More information about the hotspot-compiler-dev
mailing list