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

Unified Diff: base/tracked_objects.cc

Issue 10826018: Handle wrapping of task run count beyond 2^31 times. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/tracked_objects.cc
===================================================================
--- base/tracked_objects.cc (revision 146154)
+++ base/tracked_objects.cc (working copy)
@@ -21,7 +21,6 @@
namespace tracked_objects {
namespace {
-
// Flag to compile out almost all of the task tracking code.
const bool kTrackAllTaskObjects = true;
@@ -86,9 +85,15 @@
// Take a uniformly distributed sample over all durations ever supplied.
// The probability that we (instead) use this new sample is 1/count_. This
- // results in a completely uniform selection of the sample.
- // We ignore the fact that we correlated our selection of a sample of run
- // and queue times.
+ // results in a completely uniform selection of the sample (at least when we
+ // don't clamp count_... but that should be inconsequentially likely).
+ // We ignore the fact that we correlated our selection of a sample to the run
+ // and queue times (i.e., we used them to generate random_number).
+ if (count_ <= 0) { // Handle wrapping of count_, such as in bug 138961.
+ CHECK_GE(count_ - 1, 0); // Detect memory corruption.
+ // We'll just clamp at INT_MAX, but we should note this in the UI as such.
+ count_ = INT_MAX;
+ }
if (0 == (random_number % count_)) {
queue_duration_sample_ = queue_duration;
run_duration_sample_ = run_duration;
@@ -840,7 +845,7 @@
//------------------------------------------------------------------------------
// ParentChildPairSnapshot
-ParentChildPairSnapshot::ParentChildPairSnapshot(){
+ParentChildPairSnapshot::ParentChildPairSnapshot() {
}
ParentChildPairSnapshot::ParentChildPairSnapshot(
« 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