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

Side by Side Diff: base/metrics/histogram_snapshot_manager.cc

Issue 2148503002: Fix capture of debug information when corruption is detected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix signed/unsigned comparison Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/histogram_snapshot_manager.h" 5 #include "base/metrics/histogram_snapshot_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/metrics/histogram_flattener.h" 10 #include "base/metrics/histogram_flattener.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } else { 116 } else {
117 // First time this histogram has been seen; datafill. 117 // First time this histogram has been seen; datafill.
118 sample_info->histogram = histogram; 118 sample_info->histogram = histogram;
119 } 119 }
120 120
121 // Crash if we detect that our histograms have been overwritten. This may be 121 // Crash if we detect that our histograms have been overwritten. This may be
122 // a fair distance from the memory smasher, but we hope to correlate these 122 // a fair distance from the memory smasher, but we hope to correlate these
123 // crashes with other events, such as plugins, or usage patterns, etc. 123 // crashes with other events, such as plugins, or usage patterns, etc.
124 uint32_t corruption = histogram->FindCorruption(*samples); 124 uint32_t corruption = histogram->FindCorruption(*samples);
125 if (HistogramBase::BUCKET_ORDER_ERROR & corruption) { 125 if (HistogramBase::BUCKET_ORDER_ERROR & corruption) {
126 // Extract fields useful during debug.
127 const BucketRanges* ranges =
128 static_cast<const Histogram*>(histogram)->bucket_ranges();
129 std::vector<HistogramBase::Sample> ranges_copy;
130 for (size_t i = 0; i < ranges->size(); ++i)
131 ranges_copy.push_back(ranges->range(i));
132 HistogramBase::Sample* ranges_ptr = &ranges_copy[0];
133 const char* histogram_name = histogram->histogram_name().c_str();
134 int32_t flags = histogram->flags();
126 // The checksum should have caught this, so crash separately if it didn't. 135 // The checksum should have caught this, so crash separately if it didn't.
127 CHECK_NE(0U, HistogramBase::RANGE_CHECKSUM_ERROR & corruption); 136 CHECK_NE(0U, HistogramBase::RANGE_CHECKSUM_ERROR & corruption);
128 CHECK(false); // Crash for the bucket order corruption. 137 CHECK(false); // Crash for the bucket order corruption.
129 // Ensure that compiler keeps around pointers to |histogram| and its 138 // Ensure that compiler keeps around pointers to |histogram| and its
130 // internal |bucket_ranges_| for any minidumps. 139 // internal |bucket_ranges_| for any minidumps.
131 base::debug::Alias( 140 base::debug::Alias(&ranges_ptr);
132 static_cast<const Histogram*>(histogram)->bucket_ranges()); 141 base::debug::Alias(&histogram_name);
142 base::debug::Alias(&flags);
133 } 143 }
134 // Checksum corruption might not have caused order corruption. 144 // Checksum corruption might not have caused order corruption.
135 CHECK_EQ(0U, HistogramBase::RANGE_CHECKSUM_ERROR & corruption); 145 CHECK_EQ(0U, HistogramBase::RANGE_CHECKSUM_ERROR & corruption);
136 146
137 // Note, at this point corruption can only be COUNT_HIGH_ERROR or 147 // Note, at this point corruption can only be COUNT_HIGH_ERROR or
138 // COUNT_LOW_ERROR and they never arise together, so we don't need to extract 148 // COUNT_LOW_ERROR and they never arise together, so we don't need to extract
139 // bits from corruption. 149 // bits from corruption.
140 if (corruption) { 150 if (corruption) {
141 DLOG(ERROR) << "Histogram: \"" << histogram->histogram_name() 151 DLOG(ERROR) << "Histogram: \"" << histogram->histogram_name()
142 << "\" has data corruption: " << corruption; 152 << "\" has data corruption: " << corruption;
(...skipping 28 matching lines...) Expand all
171 181
172 histogram_flattener_->InconsistencyDetectedInLoggedCount(discrepancy); 182 histogram_flattener_->InconsistencyDetectedInLoggedCount(discrepancy);
173 if (discrepancy > Histogram::kCommonRaceBasedCountMismatch) { 183 if (discrepancy > Histogram::kCommonRaceBasedCountMismatch) {
174 // Fix logged_samples. 184 // Fix logged_samples.
175 logged_samples->Subtract(*logged_samples); 185 logged_samples->Subtract(*logged_samples);
176 logged_samples->Add(new_snapshot); 186 logged_samples->Add(new_snapshot);
177 } 187 }
178 } 188 }
179 189
180 } // namespace base 190 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698