From b416e15a7b7189619c70b6a3939413bc8286bae9 Mon Sep 17 00:00:00 2001 From: MBaesken Date: Fri, 6 Dec 2024 11:15:43 +0100 Subject: [PATCH 1/4] JDK-8345569 --- src/hotspot/share/cds/filemap.cpp | 2 +- src/hotspot/share/memory/virtualspace.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp index 594d8817322fd..4d8463fb1678f 100644 --- a/src/hotspot/share/cds/filemap.cpp +++ b/src/hotspot/share/cds/filemap.cpp @@ -2245,7 +2245,7 @@ address FileMapInfo::heap_region_requested_address() { // Runtime base = 0x4000 and shift is also 0. If we map this region at 0x5000, then // the value P can remain 0x1200. The decoded address = (0x4000 + (0x1200 << 0)) = 0x5200, // which is the runtime location of the referenced object. - return /*runtime*/ CompressedOops::base() + r->mapping_offset(); + return /*runtime*/ (address)((uintptr_t)CompressedOops::base() + r->mapping_offset()); } else { // This was the hard-coded requested base address used at dump time. With uncompressed oops, // the heap range is assigned by the OS so we will most likely have to relocate anyway, no matter diff --git a/src/hotspot/share/memory/virtualspace.cpp b/src/hotspot/share/memory/virtualspace.cpp index 33574f7f5d1ea..0575fdbdbaaae 100644 --- a/src/hotspot/share/memory/virtualspace.cpp +++ b/src/hotspot/share/memory/virtualspace.cpp @@ -34,6 +34,7 @@ #include "runtime/globals_extension.hpp" #include "runtime/java.hpp" #include "runtime/os.hpp" +#include "sanitizers/ub.hpp" #include "utilities/align.hpp" #include "utilities/formatBuffer.hpp" #include "utilities/powerOfTwo.hpp" @@ -435,6 +436,7 @@ void ReservedHeapSpace::try_reserve_heap(size_t size, } } +ATTRIBUTE_NO_UBSAN void ReservedHeapSpace::try_reserve_range(char *highest_start, char *lowest_start, size_t attach_point_alignment, From 89b7b72cab3171ef78a1feb5abc259e0c43dd7c4 Mon Sep 17 00:00:00 2001 From: MBaesken Date: Mon, 9 Dec 2024 15:41:20 +0100 Subject: [PATCH 2/4] address addition in FileMapInfo::heap_region_dumptime_address --- src/hotspot/share/cds/filemap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp index 4d8463fb1678f..06298949e0a12 100644 --- a/src/hotspot/share/cds/filemap.cpp +++ b/src/hotspot/share/cds/filemap.cpp @@ -2219,7 +2219,7 @@ address FileMapInfo::heap_region_dumptime_address() { assert(CDSConfig::is_using_archive(), "runtime only"); assert(is_aligned(r->mapping_offset(), sizeof(HeapWord)), "must be"); if (UseCompressedOops) { - return /*dumptime*/ narrow_oop_base() + r->mapping_offset(); + return /*dumptime*/ (address)((uintptr_t)narrow_oop_base() + r->mapping_offset()); } else { return heap_region_requested_address(); } From 5ac170453383b73a78a2c57b8d1fa82d7ae879cc Mon Sep 17 00:00:00 2001 From: MBaesken Date: Thu, 12 Dec 2024 16:15:17 +0100 Subject: [PATCH 3/4] ReservedHeapSpace::try_reserve_range remove the ubsan disabling --- src/hotspot/share/memory/virtualspace.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hotspot/share/memory/virtualspace.cpp b/src/hotspot/share/memory/virtualspace.cpp index 0575fdbdbaaae..0479a327b6d5f 100644 --- a/src/hotspot/share/memory/virtualspace.cpp +++ b/src/hotspot/share/memory/virtualspace.cpp @@ -436,7 +436,6 @@ void ReservedHeapSpace::try_reserve_heap(size_t size, } } -ATTRIBUTE_NO_UBSAN void ReservedHeapSpace::try_reserve_range(char *highest_start, char *lowest_start, size_t attach_point_alignment, @@ -459,7 +458,7 @@ void ReservedHeapSpace::try_reserve_range(char *highest_start, while (attach_point >= lowest_start && attach_point <= highest_start && // Avoid wrap around. ((_base == nullptr) || - (_base < aligned_heap_base_min_address || _base + size > upper_bound))) { + (_base < aligned_heap_base_min_address || size > (uintptr_t)(upper_bound - _base)))) { try_reserve_heap(size, alignment, page_size, attach_point); attach_point -= stepsize; } From 110730df36022dc4fc3aa124c80fe2879305a236 Mon Sep 17 00:00:00 2001 From: MBaesken Date: Fri, 13 Dec 2024 10:41:40 +0100 Subject: [PATCH 4/4] remove include --- src/hotspot/share/memory/virtualspace.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hotspot/share/memory/virtualspace.cpp b/src/hotspot/share/memory/virtualspace.cpp index 0479a327b6d5f..09caa68c41c99 100644 --- a/src/hotspot/share/memory/virtualspace.cpp +++ b/src/hotspot/share/memory/virtualspace.cpp @@ -34,7 +34,6 @@ #include "runtime/globals_extension.hpp" #include "runtime/java.hpp" #include "runtime/os.hpp" -#include "sanitizers/ub.hpp" #include "utilities/align.hpp" #include "utilities/formatBuffer.hpp" #include "utilities/powerOfTwo.hpp"