[compiler-rt] r180180 - tsan: fix crash when data race happens on out-of-bounds accesses.
Dmitry Vyukov
dvyukov at google.com
Wed Apr 24 02:20:25 PDT 2013
Author: dvyukov
Date: Wed Apr 24 04:20:25 2013
New Revision: 180180
URL: http://llvm.org/viewvc/llvm-project?rev=180180&view=rev
Log:
tsan: fix crash when data race happens on out-of-bounds accesses.
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_mman.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_mman.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_mman.cc?rev=180180&r1=180179&r2=180180&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_mman.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_mman.cc Wed Apr 24 04:20:25 2013
@@ -149,6 +149,7 @@ void *user_realloc(ThreadState *thr, upt
return 0;
if (p) {
MBlock *b = user_mblock(thr, p);
+ CHECK_NE(b, 0);
internal_memcpy(p2, p, min(b->Size(), sz));
}
}
@@ -166,10 +167,11 @@ uptr user_alloc_usable_size(ThreadState
}
MBlock *user_mblock(ThreadState *thr, void *p) {
- CHECK_NE(p, (void*)0);
+ CHECK_NE(p, 0);
Allocator *a = allocator();
void *b = a->GetBlockBegin(p);
- CHECK_NE(b, 0);
+ if (b == 0)
+ return 0;
return (MBlock*)a->GetMetaData(b);
}
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc?rev=180180&r1=180179&r2=180180&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc Wed Apr 24 04:20:25 2013
@@ -313,8 +313,9 @@ void ScopedReport::AddLocation(uptr addr
AddThread(tctx);
return;
}
- if (allocator()->PointerIsMine((void*)addr)) {
- MBlock *b = user_mblock(0, (void*)addr);
+ MBlock *b = 0;
+ if (allocator()->PointerIsMine((void*)addr)
+ && (b = user_mblock(0, (void*)addr))) {
ThreadContext *tctx = FindThreadByTidLocked(b->Tid());
void *mem = internal_alloc(MBlockReportLoc, sizeof(ReportLocation));
ReportLocation *loc = new(mem) ReportLocation();
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc?rev=180180&r1=180179&r2=180180&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc Wed Apr 24 04:20:25 2013
@@ -82,6 +82,7 @@ SyncVar* SyncTab::GetAndLock(ThreadState
// the hashmap anyway.
if (PrimaryAllocator::PointerIsMine((void*)addr)) {
MBlock *b = user_mblock(thr, (void*)addr);
+ CHECK_NE(b, 0);
MBlock::ScopedLock l(b);
SyncVar *res = 0;
for (res = b->ListHead(); res; res = res->next) {
@@ -146,6 +147,7 @@ SyncVar* SyncTab::GetAndRemove(ThreadSta
}
if (PrimaryAllocator::PointerIsMine((void*)addr)) {
MBlock *b = user_mblock(thr, (void*)addr);
+ CHECK_NE(b, 0);
SyncVar *res = 0;
{
MBlock::ScopedLock l(b);
More information about the llvm-commits
mailing list