RFR: 8318127: align_up has potential overflow [v8]
Dean Long
dlong at openjdk.org
Mon Nov 25 23:34:41 UTC 2024
On Thu, 10 Oct 2024 15:12:57 GMT, Casper Norrbin <cnorrbin at openjdk.org> wrote:
>> Hi everyone,
>>
>> The `align_up` function contained code which could potentially overflow and produce an incorrect result. This PR adds an assert to check for such.
>>
>> Additionally, two test case that previously caused an overflow have been updated to use the highest possible values that do not trigger an overflow.
>
> Casper Norrbin has updated the pull request incrementally with one additional commit since the last revision:
>
> newline at eof
Marked as reviewed by dlong (Reviewer).
src/hotspot/share/utilities/align.hpp line 75:
> 73: template<typename T, typename A, ENABLE_IF(std::is_integral<T>::value)>
> 74: constexpr T align_up(T size, A alignment) {
> 75: T mask = checked_cast<T>(alignment_mask(alignment));
Should we assert that mask >= 0 or trust that the result of alignment_mask() is never negative?
-------------
PR Review: https://git.openjdk.org/jdk/pull/20808#pullrequestreview-2459833599
PR Review Comment: https://git.openjdk.org/jdk/pull/20808#discussion_r1857471595
More information about the hotspot-dev
mailing list