From bd764cdf5d4a51a9d3286a2b0e5cc0f6a0d4198a Mon Sep 17 00:00:00 2001 From: iklam Date: Fri, 25 Apr 2025 09:20:21 -0700 Subject: [PATCH] 8351333: [ubsan] CDSMapLogger::log_region applying non-zero offset to null pointer --- src/hotspot/share/cds/archiveBuilder.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/cds/archiveBuilder.cpp b/src/hotspot/share/cds/archiveBuilder.cpp index c309de17b4cad..c1ffd60370b42 100644 --- a/src/hotspot/share/cds/archiveBuilder.cpp +++ b/src/hotspot/share/cds/archiveBuilder.cpp @@ -1201,7 +1201,7 @@ class ArchiveBuilder::CDSMapLogger : AllStatic { #undef _LOG_PREFIX // Log information about a region, whose address at dump time is [base .. top). At - // runtime, this region will be mapped to requested_base. requested_base is 0 if this + // runtime, this region will be mapped to requested_base. requested_base is nullptr if this // region will be mapped at os-selected addresses (such as the bitmap region), or will // be accessed with os::read (the header). // @@ -1210,7 +1210,11 @@ class ArchiveBuilder::CDSMapLogger : AllStatic { static void log_region(const char* name, address base, address top, address requested_base) { size_t size = top - base; base = requested_base; - top = requested_base + size; + if (requested_base == nullptr) { + top = (address)size; + } else { + top = requested_base + size; + } log_info(cds, map)("[%-18s " PTR_FORMAT " - " PTR_FORMAT " %9zu bytes]", name, p2i(base), p2i(top), size); }