Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Unified Diff: base/trace_event/heap_profiler_allocation_register.cc

Issue 2784783003: On heap tracking datastructure overflow, degrade instead of CHECK() (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/trace_event/heap_profiler_allocation_register.cc
diff --git a/base/trace_event/heap_profiler_allocation_register.cc b/base/trace_event/heap_profiler_allocation_register.cc
index 63d40611a6f6dcef24d2f524ff60ebf1994dfe62..9d30507aeceb2765a531e94e84c68b4fcb672796 100644
--- a/base/trace_event/heap_profiler_allocation_register.cc
+++ b/base/trace_event/heap_profiler_allocation_register.cc
@@ -81,12 +81,12 @@ AllocationRegister::AllocationRegister(size_t allocation_capacity,
AllocationRegister::~AllocationRegister() {
}
-void AllocationRegister::Insert(const void* address,
+bool AllocationRegister::Insert(const void* address,
Primiano Tucci (use gerrit) 2017/03/30 13:32:40 do we need this bool here? If it's just for the te
awong 2017/03/31 04:28:30 I feel like the API is cleaner to have a bool retu
Primiano Tucci (use gerrit) 2017/03/31 19:05:47 Not strong enough to justify another round on this
size_t size,
const AllocationContext& context) {
DCHECK(address != nullptr);
if (size == 0) {
- return;
+ return false;
}
AllocationInfo info = {
@@ -97,12 +97,15 @@ void AllocationRegister::Insert(const void* address,
// Try to insert the allocation.
auto index_and_flag = allocations_.Insert(address, info);
- if (!index_and_flag.second) {
+ if (!index_and_flag.second &&
+ index_and_flag.first != AllocationMap::kInvalidKVIndex) {
// |address| is already there - overwrite the allocation info.
auto& old_info = allocations_.Get(index_and_flag.first).second;
RemoveBacktrace(old_info.backtrace_index);
old_info = info;
}
+
+ return index_and_flag.second;
}
void AllocationRegister::Remove(const void* address) {

Powered by Google App Engine
This is Rietveld 408576698