Skip to content


Browse files Browse the repository at this point in the history
8241004: NMT tests fail on unaligned thread size with debug build
Backport-of: 0b20eaf
  • Loading branch information
ahmedmuhsin authored and GoeLin committed Feb 15, 2022
1 parent eb0708f commit aa42c4d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/hotspot/share/services/virtualMemoryTracker.cpp
Expand Up @@ -535,15 +535,21 @@ class SnapshotThreadStackWalker : public VirtualMemoryWalker {
address committed_start;
size_t committed_size;
size_t stack_size = rgn->base() + rgn->size() - stack_bottom;
// Align the size to work with full pages (Alpine and AIX stack top is not page aligned)
size_t aligned_stack_size = align_up(stack_size, os::vm_page_size());

ReservedMemoryRegion* region = const_cast<ReservedMemoryRegion*>(rgn);
NativeCallStack ncs; // empty stack

RegionIterator itr(stack_bottom, stack_size);
RegionIterator itr(stack_bottom, aligned_stack_size);
DEBUG_ONLY(bool found_stack = false;)
while (itr.next_committed(committed_start, committed_size)) {
assert(committed_start != NULL, "Should not be null");
assert(committed_size > 0, "Should not be 0");
// unaligned stack_size case: correct the region to fit the actual stack_size
if (stack_bottom + stack_size < committed_start + committed_size) {
committed_size = stack_bottom + stack_size - committed_start;
region->add_committed_region(committed_start, committed_size, ncs);
DEBUG_ONLY(found_stack = true;)
Expand Down

1 comment on commit aa42c4d

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.