8351333: [ubsan] CDSMapLogger::log_region applying non-zero offset to null pointer

Reviewed-by: ccheung
This commit is contained in:
Ioi Lam 2025-04-27 06:05:50 +00:00
parent 898d479800
commit 4e7b513372

View File

@ -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);
}