# HG changeset patch # User zgu # Date 1353074719 18000 # Node ID 96937297368d6f73fa1d38edc293ea0570cc889b # Parent a87ba3f13fa04e36b9e5b53acf4da192e1243a95 8003487: NMT: incorrect assertion in VMMemPointerIterator::remove_released_region method (memSnapshot.cpp) Summary: The assertion is applied to only the region to be released, also performs region integrity checking Reviewed-by: acorn, coleenp diff -r a87ba3f13fa0 -r 96937297368d hotspot/src/share/vm/services/memSnapshot.cpp --- a/hotspot/src/share/vm/services/memSnapshot.cpp Tue Nov 13 15:14:27 2012 -0500 +++ b/hotspot/src/share/vm/services/memSnapshot.cpp Fri Nov 16 09:05:19 2012 -0500 @@ -261,17 +261,19 @@ VMMemRegion* cur = (VMMemRegion*)current(); assert(cur->is_reserved_region() && cur->contains_region(rec), "Sanity check"); + if (rec->is_same_region(cur)) { + // release whole reserved region #ifdef ASSERT - VMMemRegion* next_reg = (VMMemRegion*)peek_next(); - // should not have any committed memory in this reserved region - assert(next_reg == NULL || !next_reg->is_committed_region(), "Sanity check"); + VMMemRegion* next_region = (VMMemRegion*)peek_next(); + // should not have any committed memory in this reserved region + assert(next_region == NULL || !next_region->is_committed_region(), "Sanity check"); #endif - if (rec->is_same_region(cur)) { remove(); } else if (rec->addr() == cur->addr() || rec->addr() + rec->size() == cur->addr() + cur->size()) { // released region is at either end of this region cur->exclude_region(rec->addr(), rec->size()); + assert(check_reserved_region(), "Integrity check"); } else { // split the reserved region and release the middle address high_addr = cur->addr() + cur->size(); size_t sz = high_addr - rec->addr(); @@ -280,10 +282,14 @@ if (MemTracker::track_callsite()) { MemPointerRecordEx tmp(rec->addr() + rec->size(), cur->flags(), sz, ((VMMemRegionEx*)cur)->pc()); - return insert_reserved_region(&tmp); + bool ret = insert_reserved_region(&tmp); + assert(!ret || check_reserved_region(), "Integrity check"); + return ret; } else { MemPointerRecord tmp(rec->addr() + rec->size(), cur->flags(), sz); - return insert_reserved_region(&tmp); + bool ret = insert_reserved_region(&tmp); + assert(!ret || check_reserved_region(), "Integrity check"); + return ret; } } return true; diff -r a87ba3f13fa0 -r 96937297368d hotspot/src/share/vm/services/memSnapshot.hpp --- a/hotspot/src/share/vm/services/memSnapshot.hpp Tue Nov 13 15:14:27 2012 -0500 +++ b/hotspot/src/share/vm/services/memSnapshot.hpp Fri Nov 16 09:05:19 2012 -0500 @@ -146,6 +146,23 @@ // reset current position inline void reset() { _pos = 0; } #ifdef ASSERT + // check integrity of records on current reserved memory region. + bool check_reserved_region() { + VMMemRegion* reserved_region = (VMMemRegion*)current(); + assert(reserved_region != NULL && reserved_region->is_reserved_region(), + "Sanity check"); + // all committed regions that follow current reserved region, should all + // belong to the reserved region. + VMMemRegion* next_region = (VMMemRegion*)next(); + for (; next_region != NULL && next_region->is_committed_region(); + next_region = (VMMemRegion*)next() ) { + if(!reserved_region->contains_region(next_region)) { + return false; + } + } + return true; + } + virtual bool is_dup_pointer(const MemPointer* ptr1, const MemPointer* ptr2) const { VMMemRegion* p1 = (VMMemRegion*)ptr1;