Repository: kudu
Updated Branches:
  refs/heads/master 84e0f3033 -> 136b8058f


logging: fix UBSAN unsigned int overflow in LogThrottler

Fixes the following UBSAN error:

  src/kudu/util/logging.h:333:12: runtime error: unsigned integer
  overflow: 563980051 - 563991872 cannot be represented in type 'unsigned
  long'

This was happening because we used an unsigned int64 when subtracing
timestamps, and because this function is intentionally racy, it was
possible to underflow and end up negative.

No real functional issue fixed here since the worst that would happen
was an extra (non-throttled) log message when the race triggered.

Change-Id: Ib2078b5f49dc3c751b4bb7db893506494c758289
Reviewed-on: http://gerrit.cloudera.org:8080/9289
Reviewed-by: Dan Burkert <d...@cloudera.com>
Tested-by: Todd Lipcon <t...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/c9c86f47
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/c9c86f47
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/c9c86f47

Branch: refs/heads/master
Commit: c9c86f4788c42b864bf0e8aaebcd03d75f5a6e9b
Parents: 84e0f30
Author: Todd Lipcon <t...@apache.org>
Authored: Mon Feb 12 15:26:16 2018 -0800
Committer: Todd Lipcon <t...@apache.org>
Committed: Tue Feb 13 00:12:41 2018 +0000

----------------------------------------------------------------------
 src/kudu/util/logging.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/c9c86f47/src/kudu/util/logging.h
----------------------------------------------------------------------
diff --git a/src/kudu/util/logging.h b/src/kudu/util/logging.h
index bfc4c59..442f94b 100644
--- a/src/kudu/util/logging.h
+++ b/src/kudu/util/logging.h
@@ -340,7 +340,7 @@ class LogThrottler {
   }
  private:
   Atomic32 num_suppressed_;
-  uint64_t last_ts_;
+  MicrosecondsInt64 last_ts_;
   const char* last_tag_;
 };
 } // namespace logging

Reply via email to