diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2012-09-17 03:14:15 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2012-09-17 03:14:15 +0000 |
commit | d0dc91869f197d2df69ceaecce0889931e18de67 (patch) | |
tree | 65c7caee840541789f2d69a4d46ee418a34bf4a9 /lib/sanitizer_common/sanitizer_stackdepot.cc | |
parent | df11061d6df6e7018c34fc23274c40c36db4731a (diff) | |
download | compiler-rt-d0dc91869f197d2df69ceaecce0889931e18de67.tar.gz |
tsan: reserve msb in stack depot id's (required for msan)
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@164010 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_stackdepot.cc')
-rw-r--r-- | lib/sanitizer_common/sanitizer_stackdepot.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/sanitizer_common/sanitizer_stackdepot.cc b/lib/sanitizer_common/sanitizer_stackdepot.cc index 801abc430..6fb3d2dcb 100644 --- a/lib/sanitizer_common/sanitizer_stackdepot.cc +++ b/lib/sanitizer_common/sanitizer_stackdepot.cc @@ -13,14 +13,15 @@ #include "sanitizer_stackdepot.h" #include "sanitizer_common.h" +#include "sanitizer_internal_defs.h" #include "sanitizer_mutex.h" #include "sanitizer_atomic.h" namespace __sanitizer { const int kTabSize = 1024 * 1024; // Hash table size. -const int kPartBits = 10; -const int kPartShift = sizeof(u32) * 8 - kPartBits; +const int kPartBits = 8; +const int kPartShift = sizeof(u32) * 8 - kPartBits - 1; const int kPartCount = 1 << kPartBits; // Number of subparts in the table. const int kPartSize = kTabSize / kPartCount; const int kMaxId = 1 << kPartShift; @@ -157,6 +158,8 @@ u32 StackDepotPut(const uptr *stack, uptr size) { id = atomic_fetch_add(&depot.seq[part], 1, memory_order_relaxed) + 1; CHECK_LT(id, kMaxId); id |= part << kPartShift; + CHECK_NE(id, 0); + CHECK_EQ(id & (1u << 31), 0); s = allocDesc(size); s->id = id; s->hash = h; @@ -170,6 +173,7 @@ u32 StackDepotPut(const uptr *stack, uptr size) { const uptr *StackDepotGet(u32 id, uptr *size) { if (id == 0) return 0; + CHECK_EQ(id & (1u << 31), 0); // High kPartBits contain part id, so we need to scan at most kPartSize lists. uptr part = id >> kPartShift; for (int i = 0; i != kPartSize; i++) { |