diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2014-07-08 13:28:01 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2014-07-08 13:28:01 +0000 |
commit | a1d2b483b9468c644f3895974ef578e2d20703c8 (patch) | |
tree | b779d3089b0a425fcccf5e6ac9a852bfdcd1ca68 /lib/tsan/tests | |
parent | d9846b65edc09ee1dc41b3cdb8d55629394aad3d (diff) |
tsan: fix a bug in metamap
The bug happens in the following case:
Mutex is located at heap block beginning,
when we call MutexDestroy, s->next is set to 0,
so free can't find the MBlock related to the block.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@212531 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/tests')
-rw-r--r-- | lib/tsan/tests/unit/tsan_sync_test.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/tsan/tests/unit/tsan_sync_test.cc b/lib/tsan/tests/unit/tsan_sync_test.cc index 664ce7f0d..6f36c64a5 100644 --- a/lib/tsan/tests/unit/tsan_sync_test.cc +++ b/lib/tsan/tests/unit/tsan_sync_test.cc @@ -108,4 +108,16 @@ TEST(MetaMap, MoveMemory) { m->FreeRange(thr, 0, (uptr)&block2[0], 4 * sizeof(u64)); } +TEST(MetaMap, ResetSync) { + ThreadState *thr = cur_thread(); + MetaMap *m = &ctx->metamap; + u64 block[1] = {}; // fake malloc block + m->AllocBlock(thr, 0, (uptr)&block[0], 1 * sizeof(u64)); + SyncVar *s = m->GetOrCreateAndLock(thr, 0, (uptr)&block[0], true); + s->Reset(); + s->mtx.Unlock(); + uptr sz = m->FreeBlock(thr, 0, (uptr)&block[0]); + EXPECT_EQ(sz, 1 * sizeof(u64)); +} + } // namespace __tsan |