Skip to content

Commit 196c6cc

Browse files
committed
8345569: [ubsan] adjustments to filemap.cpp and virtualspace.cpp for macOS aarch64
Backport-of: 1d2ccaeaa316029772b5de3dc5579ee7b1363b60
1 parent 8b4ee65 commit 196c6cc

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/hotspot/share/cds/filemap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,7 +2024,7 @@ address FileMapInfo::heap_region_dumptime_address() {
20242024
assert(UseSharedSpaces, "runtime only");
20252025
assert(is_aligned(r->mapping_offset(), sizeof(HeapWord)), "must be");
20262026
if (UseCompressedOops) {
2027-
return /*dumptime*/ narrow_oop_base() + r->mapping_offset();
2027+
return /*dumptime*/ (address)((uintptr_t)narrow_oop_base() + r->mapping_offset());
20282028
} else {
20292029
return heap_region_requested_address();
20302030
}
@@ -2050,7 +2050,7 @@ address FileMapInfo::heap_region_requested_address() {
20502050
// Runtime base = 0x4000 and shift is also 0. If we map this region at 0x5000, then
20512051
// the value P can remain 0x1200. The decoded address = (0x4000 + (0x1200 << 0)) = 0x5200,
20522052
// which is the runtime location of the referenced object.
2053-
return /*runtime*/ CompressedOops::base() + r->mapping_offset();
2053+
return /*runtime*/ (address)((uintptr_t)CompressedOops::base() + r->mapping_offset());
20542054
} else {
20552055
// We can avoid relocation if each region is mapped into the exact same address
20562056
// where it was at dump time.

src/hotspot/share/memory/virtualspace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ void ReservedHeapSpace::try_reserve_range(char *highest_start,
437437
while (attach_point >= lowest_start &&
438438
attach_point <= highest_start && // Avoid wrap around.
439439
((_base == nullptr) ||
440-
(_base < aligned_heap_base_min_address || _base + size > upper_bound))) {
440+
(_base < aligned_heap_base_min_address || size > (uintptr_t)(upper_bound - _base)))) {
441441
try_reserve_heap(size, alignment, page_size, attach_point);
442442
attach_point -= stepsize;
443443
}

0 commit comments

Comments
 (0)