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

Afshin Zafari azafari at openjdk.org
Tue Nov 25 10:19:38 UTC 2025


> 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/489bd199...56f8b1f3

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/26955/files
  - new: https://git.openjdk.org/jdk/pull/26955/files/d1294f6e..56f8b1f3

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=26955&range=12
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=26955&range=11-12

  Stats: 263566 lines in 2393 files changed: 177469 ins; 47924 del; 38173 mod
  Patch: https://git.openjdk.org/jdk/pull/26955.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26955/head:pull/26955

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


More information about the hotspot-dev mailing list