Skip to content

Commit db12f19

Browse files
author
Afshin Zafari
committed
8364280: NMTCommittedVirtualMemoryTracker.test_committed_virtualmemory_region_vm fails with assertion "negative distance"
Reviewed-by: gziemski, jsjolen
1 parent d78fa5a commit db12f19

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

test/hotspot/gtest/runtime/test_committed_virtualmemory.cpp

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,37 @@ class CommittedVirtualMemoryTest {
4343
// snapshot current stack usage
4444
VirtualMemoryTracker::Instance::snapshot_thread_stacks();
4545

46-
ReservedMemoryRegion rmr_found = VirtualMemoryTracker::Instance::tree()->find_reserved_region(stack_end);
46+
ReservedMemoryRegion rmr_found;
47+
{
48+
MemTracker::NmtVirtualMemoryLocker vml;
49+
rmr_found = VirtualMemoryTracker::Instance::tree()->find_reserved_region(stack_end);
50+
}
51+
4752
ASSERT_TRUE(rmr_found.is_valid());
4853
ASSERT_EQ(rmr_found.base(), stack_end);
4954

55+
5056
int i = 0;
5157
address i_addr = (address)&i;
5258
bool found_i_addr = false;
5359

5460
// stack grows downward
5561
address stack_top = stack_end + stack_size;
5662
bool found_stack_top = false;
57-
VirtualMemoryTracker::Instance::tree()->visit_committed_regions(rmr_found, [&](const CommittedMemoryRegion& cmr) {
58-
if (cmr.base() + cmr.size() == stack_top) {
59-
EXPECT_TRUE(cmr.size() <= stack_size);
60-
found_stack_top = true;
61-
}
62-
if(i_addr < stack_top && i_addr >= cmr.base()) {
63-
found_i_addr = true;
64-
}
65-
i++;
66-
return true;
67-
});
68-
63+
{
64+
MemTracker::NmtVirtualMemoryLocker vml;
65+
VirtualMemoryTracker::Instance::tree()->visit_committed_regions(rmr_found, [&](const CommittedMemoryRegion& cmr) {
66+
if (cmr.base() + cmr.size() == stack_top) {
67+
EXPECT_TRUE(cmr.size() <= stack_size);
68+
found_stack_top = true;
69+
}
70+
if (i_addr < stack_top && i_addr >= cmr.base()) {
71+
found_i_addr = true;
72+
}
73+
i++;
74+
return true;
75+
});
76+
}
6977

7078
// stack and guard pages may be contiguous as one region
7179
ASSERT_TRUE(i >= 1);

0 commit comments

Comments
 (0)