Fix mmap region iteration while no regions are recorded.

If no mmap regions are recorded, iteration failed since the
RegionSet (std::set) object is not initialized.

BUG=162208
R=willchan@chromium.org

Review URL: https://codereview.chromium.org/14769008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198878 0039d316-1c4b-4281-b951-d872f2087c98
parent 02a7c279
......@@ -646,8 +646,11 @@ void DeepHeapProfile::GlobalStats::SnapshotMaps(
MemoryRegionMap::RegionIterator mmap_iter =
MemoryRegionMap::BeginRegionLocked();
DeepBucket* deep_bucket = GetInformationOfMemoryRegion(
mmap_iter, memory_residence_info_getter, deep_profile);
DeepBucket* deep_bucket = NULL;
if (mmap_iter != MemoryRegionMap::EndRegionLocked()) {
deep_bucket = GetInformationOfMemoryRegion(
mmap_iter, memory_residence_info_getter, deep_profile);
}
while (procmaps_iter.Next(&vma_start_addr, &vma_last_addr,
&flags, &offset, &inode, &filename)) {
......
......@@ -231,6 +231,8 @@ void MemoryRegionMap::Init(int max_stack_depth, bool use_buckets) {
memset(bucket_table_, 0, table_bytes);
num_buckets_ = 0;
}
if (regions_ == NULL) // init regions_
InitRegionSetLocked();
Unlock();
RAW_VLOG(10, "MemoryRegionMap Init done");
}
......@@ -533,6 +535,15 @@ void MemoryRegionMap::RestoreSavedBucketsLocked() {
}
}
inline void MemoryRegionMap::InitRegionSetLocked() {
RAW_VLOG(12, "Initializing region set");
regions_ = regions_rep.region_set();
recursive_insert = true;
new(regions_) RegionSet();
HandleSavedRegionsLocked(&DoInsertRegionLocked);
recursive_insert = false;
}
inline void MemoryRegionMap::InsertRegionLocked(const Region& region) {
RAW_CHECK(LockIsHeld(), "should be held (by this thread)");
// We can be called recursively, because RegionSet constructor
......@@ -552,14 +563,8 @@ inline void MemoryRegionMap::InsertRegionLocked(const Region& region) {
// then increment saved_regions_count.
saved_regions[saved_regions_count++] = region;
} else { // not a recusrive call
if (regions_ == NULL) { // init regions_
RAW_VLOG(12, "Initializing region set");
regions_ = regions_rep.region_set();
recursive_insert = true;
new(regions_) RegionSet();
HandleSavedRegionsLocked(&DoInsertRegionLocked);
recursive_insert = false;
}
if (regions_ == NULL) // init regions_
InitRegionSetLocked();
recursive_insert = true;
// Do the actual insertion work to put new regions into regions_:
DoInsertRegionLocked(region);
......
......@@ -361,6 +361,9 @@ class MemoryRegionMap {
// table where all buckets eventually should be.
static void RestoreSavedBucketsLocked();
// Initialize RegionSet regions_.
inline static void InitRegionSetLocked();
// Wrapper around DoInsertRegionLocked
// that handles the case of recursive allocator calls.
inline static void InsertRegionLocked(const Region& region);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment