加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Fix-mmap-region-iteration-while-no-regions-are-recor.patch 2.81 KB
一键复制 编辑 原始数据 按行查看 历史
hexiaowen 提交于 2019-09-30 10:51 . Package init
From 1de76671d478e848f0dd210e00df43bfa463ca9f Mon Sep 17 00:00:00 2001
From: Gabriel Marin <gmx@chromium.org>
Date: Thu, 4 Oct 2018 22:52:35 +0000
Subject: [PATCH 31/39] 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.
Original CL https://codereview.chromium.org/14769008
Reviewed-on: https://chromium-review.googlesource.com/c/1130807
---
src/memory_region_map.cc | 19 +++++++++++++------
src/memory_region_map.h | 3 +++
2 files changed, 16 insertions(+), 6 deletions(-)
mode change 100755 => 100644 src/memory_region_map.cc
diff --git a/src/memory_region_map.cc b/src/memory_region_map.cc
old mode 100755
new mode 100644
index 841d6f3..06b6fb0
--- a/src/memory_region_map.cc
+++ b/src/memory_region_map.cc
@@ -234,6 +234,9 @@ 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");
}
@@ -536,6 +539,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
@@ -556,12 +568,7 @@ inline void MemoryRegionMap::InsertRegionLocked(const Region& region) {
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;
+ InitRegionSetLocked();
}
recursive_insert = true;
// Do the actual insertion work to put new regions into regions_:
diff --git a/src/memory_region_map.h b/src/memory_region_map.h
index ec388e1..f774994 100644
--- a/src/memory_region_map.h
+++ b/src/memory_region_map.h
@@ -362,6 +362,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);
--
1.8.3.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化