From 3fbae32d0a9dbe612d4170e135a813c114fdcec2 Mon Sep 17 00:00:00 2001 From: SendaoYan Date: Thu, 6 Feb 2025 15:01:05 +0000 Subject: [PATCH] 8349465: [UBSAN] test_os_reserve_between.cpp reported applying non-zero offset to null pointer Reviewed-by: mdoerr, amitkumar --- test/hotspot/gtest/runtime/test_os_reserve_between.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/gtest/runtime/test_os_reserve_between.cpp b/test/hotspot/gtest/runtime/test_os_reserve_between.cpp index 64482bb40a3..7e326fda439 100644 --- a/test/hotspot/gtest/runtime/test_os_reserve_between.cpp +++ b/test/hotspot/gtest/runtime/test_os_reserve_between.cpp @@ -284,7 +284,7 @@ TEST_VM(os, attempt_reserve_memory_between_combos) { for (size_t range_size = allocation_granularity(); range_size <= large_end; range_size *= 2) { for (size_t start_offset = 0; start_offset <= large_end; start_offset += (large_end / 2)) { char* const min = (char*)(uintptr_t)start_offset; - char* const max = min + range_size; + char* const max = (char*)(p2u(min) + range_size); for (size_t bytes = os::vm_page_size(); bytes < large_end; bytes *= 2) { for (size_t alignment = allocation_granularity(); alignment < large_end; alignment *= 2) { test_attempt_reserve_memory_between(min, max, bytes, alignment, true, Expect::dontcare(), __LINE__);