RFR: 8328934: Assert that ABS input and output are legal [v3]

Andrew Haley aph at openjdk.org
Fri Apr 12 10:05:56 UTC 2024


On Fri, 12 Apr 2024 09:21:54 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> This should protect us from future accidents around `abs` misuse. We have fixed a few separately. I plan to use this as the litmus test in update releases to detect missing backports for actual fixes. I am running more tests to see if we have any other sightings in current codebase, but this can be reviewed for sanity meanwhile.
>> 
>> Additional testing:
>>  - [x] MacOS AArch64 server fastdebug build passes
>>  - [ ] Linux x86_64 server fastdebug, `all`
>>  - [ ] Linux x86_64 server fastdebug, 100K Fuzzer tests
>>  - [ ] Linux x86_64 server fastdebug, Maven CTW
>>  - [ ] Linux AArch64 server fastdebug, `all`
>
> Aleksey Shipilev has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Only assert integral type arguments

src/hotspot/share/utilities/globalDefinitions.hpp line 1112:

> 1110:   assert(!std::is_integral<T>::value || x != std::numeric_limits<T>::min(),
> 1111:          "ABS: argument should not allow overflow");
> 1112:   T res = (x > 0) ? x : -x;

Beware! If x is MIN_INT, GCC might delete the assertion because the negation below is UB. I'd only do the negation if it won't overflow.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18751#discussion_r1562334907


More information about the hotspot-dev mailing list