RFR: 8366062: [ubsan] add non-zero offset to nullptr in cds/archiveBuilder.cpp [v8]

Ioi Lam iklam at openjdk.org
Fri Oct 31 01:22:06 UTC 2025


On Thu, 30 Oct 2025 09:28:56 GMT, Afshin Zafari <azafari at openjdk.org> wrote:

>> It is acceptable that the `SharedBaseAddress` option gets `0` at command line. The corresponding pointer arithmetic with `0` (`nullptr`) in archiveBuilder is UB.
>> Specific casts are used to avoid UBSAN error.
>> 
>> Tests:
>> linux-x64-debug: tier1 passed
>
> Afshin Zafari has updated the pull request incrementally with one additional commit since the last revision:
> 
>   suggested change is applied. one error is addressed. one remains still.

src/hotspot/share/cds/archiveBuilder.cpp line 1035:

> 1033: 
> 1034: address ArchiveBuilder::offset_to_buffered_address(u4 offset) const {
> 1035:   // As zero is allowed for _requested_static_archive_bottom, use integer arithmetic to avoid UB pointer arithmetic.

This comment is no longer needed.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26983#discussion_r2479910240


More information about the hotspot-runtime-dev mailing list