Skip to content

Commit 9eaa364

Browse files
author
Afshin Zafari
committed
8361487: [ubsan] test_committed_virtualmemory.cpp check_covered_pages shows overflow
Reviewed-by: jsjolen, phubner
1 parent 81e0c87 commit 9eaa364

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,21 @@ class CommittedVirtualMemoryTest {
8383
ASSERT_TRUE(found_stack_top);
8484
}
8585

86+
static const int PAGE_CONTAINED_IN_RANGE_TAG = -1;
87+
static bool is_page_in_committed_region(int a) { return (a == PAGE_CONTAINED_IN_RANGE_TAG); }
88+
static void set_page_as_contained_in_committed_region(int &a) { a = PAGE_CONTAINED_IN_RANGE_TAG; }
89+
8690
static void check_covered_pages(address addr, size_t size, address base, size_t touch_pages, int* page_num) {
8791
const size_t page_sz = os::vm_page_size();
8892
size_t index;
8993
for (index = 0; index < touch_pages; index ++) {
94+
if (is_page_in_committed_region(page_num[index])) { // Already tagged?
95+
continue;
96+
}
9097
address page_addr = base + page_num[index] * page_sz;
9198
// The range covers this page, marks the page
9299
if (page_addr >= addr && page_addr < addr + size) {
93-
page_num[index] = -1;
100+
set_page_as_contained_in_committed_region(page_num[index]);
94101
}
95102
}
96103
}
@@ -135,7 +142,7 @@ class CommittedVirtualMemoryTest {
135142
if (precise_tracking_supported) {
136143
// All touched pages should be committed
137144
for (size_t index = 0; index < touch_pages; index ++) {
138-
ASSERT_EQ(page_num[index], -1);
145+
ASSERT_TRUE(is_page_in_committed_region(page_num[index]));
139146
}
140147
}
141148

0 commit comments

Comments
 (0)