From 9eaa364a5221cba960467ffbaea14ea790809c6a Mon Sep 17 00:00:00 2001 From: Afshin Zafari Date: Fri, 14 Nov 2025 09:03:11 +0000 Subject: [PATCH] 8361487: [ubsan] test_committed_virtualmemory.cpp check_covered_pages shows overflow Reviewed-by: jsjolen, phubner --- .../gtest/runtime/test_committed_virtualmemory.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp b/test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp index 4d3fc1ff82e..5b78a66a3ae 100644 --- a/test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp +++ b/test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp @@ -83,14 +83,21 @@ public: ASSERT_TRUE(found_stack_top); } + static const int PAGE_CONTAINED_IN_RANGE_TAG = -1; + static bool is_page_in_committed_region(int a) { return (a == PAGE_CONTAINED_IN_RANGE_TAG); } + static void set_page_as_contained_in_committed_region(int &a) { a = PAGE_CONTAINED_IN_RANGE_TAG; } + static void check_covered_pages(address addr, size_t size, address base, size_t touch_pages, int* page_num) { const size_t page_sz = os::vm_page_size(); size_t index; for (index = 0; index < touch_pages; index ++) { + if (is_page_in_committed_region(page_num[index])) { // Already tagged? + continue; + } address page_addr = base + page_num[index] * page_sz; // The range covers this page, marks the page if (page_addr >= addr && page_addr < addr + size) { - page_num[index] = -1; + set_page_as_contained_in_committed_region(page_num[index]); } } } @@ -135,7 +142,7 @@ public: if (precise_tracking_supported) { // All touched pages should be committed for (size_t index = 0; index < touch_pages; index ++) { - ASSERT_EQ(page_num[index], -1); + ASSERT_TRUE(is_page_in_committed_region(page_num[index])); } }