Skip to content

8360048: NMT crash in gtest/NMTGtests.java: fatal error: NMT corruption: Block at 0x0000017748307120: header canary broken #25950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hotspot/share/nmt/memBaseline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ bool MemBaseline::aggregate_virtual_memory_allocation_sites() {
site = node->data();
}
site->reserve_memory(rgn->size());
site->commit_memory(rgn->committed_size());
site->commit_memory(VirtualMemoryTracker::Instance::committed_size(rgn));
}

_virtual_memory_sites.move(&allocation_sites);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/nmt/memReporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void MemDetailReporter::report_virtual_memory_region(const ReservedMemoryRegion*
outputStream* out = output();
const char* scale = current_scale();
const NativeCallStack* stack = reserved_rgn->call_stack();
bool all_committed = reserved_rgn->size() == reserved_rgn->committed_size();
bool all_committed = reserved_rgn->size() == VirtualMemoryTracker::Instance::committed_size(reserved_rgn);
const char* region_type = (all_committed ? "reserved and committed" : "reserved");
out->cr();
print_virtual_memory_region(region_type, reserved_rgn->base(), reserved_rgn->size());
Expand Down
25 changes: 17 additions & 8 deletions src/hotspot/share/nmt/virtualMemoryTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,29 @@ bool VirtualMemoryTracker::walk_virtual_memory(VirtualMemoryWalker* walker) {
return true;
}

size_t ReservedMemoryRegion::committed_size() const {
size_t committed = 0;
size_t VirtualMemoryTracker::committed_size(const ReservedMemoryRegion* rmr) {
size_t result = 0;
VirtualMemoryTracker::Instance::tree()->visit_committed_regions(*this, [&](CommittedMemoryRegion& crgn) {
tree()->visit_committed_regions(*rmr, [&](CommittedMemoryRegion& crgn) {
result += crgn.size();
return true;
});
return result;
}

address ReservedMemoryRegion::thread_stack_uncommitted_bottom() const {
address bottom = base();
address top = base() + size();
VirtualMemoryTracker::Instance::tree()->visit_committed_regions(*this, [&](CommittedMemoryRegion& crgn) {
size_t VirtualMemoryTracker::Instance::committed_size(const ReservedMemoryRegion* rmr) {
assert(_tracker != nullptr, "Sanity check");
return _tracker->committed_size(rmr);
}

address VirtualMemoryTracker::Instance::thread_stack_uncommitted_bottom(const ReservedMemoryRegion* rmr) {
assert(_tracker != nullptr, "Sanity check");
return _tracker->thread_stack_uncommitted_bottom(rmr);
}

address VirtualMemoryTracker::thread_stack_uncommitted_bottom(const ReservedMemoryRegion* rmr) {
address bottom = rmr->base();
address top = rmr->end();
tree()->visit_committed_regions(*rmr, [&](CommittedMemoryRegion& crgn) {
address committed_top = crgn.base() + crgn.size();
if (committed_top < top) {
// committed stack guard pages, skip them
Expand Down Expand Up @@ -291,7 +300,7 @@ class SnapshotThreadStackWalker : public VirtualMemoryWalker {
assert_lock_strong(NmtVirtualMemory_lock);
}
if (rgn->mem_tag() == mtThreadStack) {
address stack_bottom = rgn->thread_stack_uncommitted_bottom();
address stack_bottom = VirtualMemoryTracker::Instance::thread_stack_uncommitted_bottom(rgn);
address committed_start;
size_t committed_size;
size_t stack_size = rgn->base() + rgn->size() - stack_bottom;
Expand Down
12 changes: 6 additions & 6 deletions src/hotspot/share/nmt/virtualMemoryTracker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,6 @@ class ReservedMemoryRegion : public VirtualMemoryRegion {

inline MemTag mem_tag() const { return _mem_tag; }

// uncommitted thread stack bottom, above guard pages if there is any.
address thread_stack_uncommitted_bottom() const;

size_t committed_size() const;


ReservedMemoryRegion& operator= (const ReservedMemoryRegion& other) {
set_base(other.base());
set_size(other.size());
Expand Down Expand Up @@ -382,6 +376,9 @@ class VirtualMemoryTracker {
// Snapshot current thread stacks
void snapshot_thread_stacks();
void apply_summary_diff(VMATree::SummaryDiff diff);
size_t committed_size(const ReservedMemoryRegion* rmr);
address thread_stack_uncommitted_bottom(const ReservedMemoryRegion* rmr);

RegionsTree* tree() { return &_tree; }

class Instance : public AllStatic {
Expand All @@ -404,6 +401,9 @@ class VirtualMemoryTracker {
static bool print_containing_region(const void* p, outputStream* st);
static void snapshot_thread_stacks();
static void apply_summary_diff(VMATree::SummaryDiff diff);
static size_t committed_size(const ReservedMemoryRegion* rmr);
// uncommitted thread stack bottom, above guard pages if there is any.
static address thread_stack_uncommitted_bottom(const ReservedMemoryRegion* rmr);

static RegionsTree* tree() { return _tracker->tree(); }
};
Expand Down
Loading