RFR: 8361487: [ubsan] test_committed_virtualmemory.cpp check_covered_pages shows overflow [v3]

Johan Sjölen jsjolen at openjdk.org
Thu Nov 13 14:36:31 UTC 2025


On Thu, 13 Nov 2025 13:34:55 GMT, Afshin Zafari <azafari at openjdk.org> wrote:

>> In the test,  page-numbers to be checked are passed to a checker function in which they will be changed to `-1` if they are as expected.
>> Use of these `-1` values for page-numbers in consequent checks result in overflow in pointer arithmetic of `base + (-1) * page_size` which is certainly less than `base`.
>> 
>> The fix is to skip cases where page-number under checking is `-1`.
>> Tested under UBSAN build.
>
> Afshin Zafari has updated the pull request incrementally with one additional commit since the last revision:
> 
>   better comment

Marked as reviewed by jsjolen (Reviewer).

test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp line 88:

> 86:   static constexpr int PAGE_CONTAINED_IN_RANGE_TAG = -1;
> 87:   static constexpr bool IS_PAGE_CONTAINED_IN_COMMITTED_REGION(int a) { return (a == PAGE_CONTAINED_IN_RANGE_TAG); }
> 88:   static constexpr void SET_PAGE_AS_CONTAINED_IN_COMMITTED_REGION(int &a) { a = PAGE_CONTAINED_IN_RANGE_TAG; }

The functions aren't `constexpr`, so you can skip those. I think all of these can be in `this_style_of_naming` instead.

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

PR Review: https://git.openjdk.org/jdk/pull/28151#pullrequestreview-3460097474
PR Review Comment: https://git.openjdk.org/jdk/pull/28151#discussion_r2523708175


More information about the hotspot-runtime-dev mailing list