RFR: 8351334: [ubsan] memoryReserver.cpp:552:60: runtime error: applying non-zero offset 1073741824 to null pointer [v13]

Johan Sjölen jsjolen at openjdk.org
Thu Nov 27 12:58:00 UTC 2025


On Tue, 25 Nov 2025 10:19:38 GMT, Afshin Zafari <azafari at openjdk.org> wrote:

>> The issue happens when the HeapMinBaseAddress option gets 0 as input value. Since this option is used as an address, then using 0 in pointer arithmetics is UB.
>> The fix is using `unitptr_t` instead of `address`/`char*`, etc.  In doing that, it is found that an overflow check does not work in all cases due to checking more conditions. That overflow check is changed too. We also need to check overflow after aligning addresses and sizes of memory regions in this context. Assertions are added to check these cases.
>> 
>> Tests:
>> linux-x64 tier1
>
> Afshin Zafari has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 13 additional commits since the last revision:
> 
>  - Merge remote-tracking branch 'origin/master' into _8351334_ubsan_nullptr_add
>  - better type
>  - fix arguments.cpp for HeapMinBaseAddress type.
>  - Merge remote-tracking branch 'origin/master' into _8351334_ubsan_nullptr_add
>  - removed redundant check of overflow.
>  - subtraction for checking overflow
>  - fixed MAX2 template parameter
>  - fixes.
>  - uintptr_t -> uint64_t
>  - fixes
>  - ... and 3 more: https://git.openjdk.org/jdk/compare/0ab6af85...56f8b1f3

Marked as reviewed by jsjolen (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/26955#pullrequestreview-3515205954


More information about the hotspot-dev mailing list