Integrated: 8346916: [REDO] align_up has potential overflow

Casper Norrbin cnorrbin at openjdk.org
Thu Mar 13 09:38:59 UTC 2025


On Thu, 20 Feb 2025 10:48:26 GMT, Casper Norrbin <cnorrbin at openjdk.org> wrote:

> Hi everyone,
> 
> The `align_up` function can potentially overflow, resulting in undefined behavior. Most use cases rely on the assumption that aligned_result >= original. To address this, I've added an assertion to verify this condition.
> 
> The original PR (#20808) missed cases where overflow checks already existed, so I've now went through usages of `align_up` and found the places with explicit checks. Most notably, #23168 added `align_up_or_null` to metaspace, but this function is also useful elsewhere. Given this, I relocated it to `align.hpp`, alongside the rest of the alignment functions.

This pull request has now been integrated.

Changeset: 86860cac
Author:    Casper Norrbin <cnorrbin at openjdk.org>
Committer: Albert Mingkun Yang <ayang at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/86860cac044e6f464732753670b14a80c1fef438
Stats:     132 lines in 6 files changed: 95 ins; 29 del; 8 mod

8346916: [REDO] align_up has potential overflow

Reviewed-by: ayang, kbarrett, dlong

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

PR: https://git.openjdk.org/jdk/pull/23711


More information about the hotspot-dev mailing list