[Tsan] Do not sanitize memcpy() during thread initialization on FreeBSD

Differential Revision: http://reviews.llvm.org/D8324

llvm-svn: 232381
This commit is contained in:
Viktor Kutuzov 2015-03-16 14:42:21 +00:00
parent 10fa53d26e
commit a7d323e996
4 changed files with 10 additions and 5 deletions

View File

@ -413,7 +413,7 @@ static void JmpBufGarbageCollect(ThreadState *thr, uptr sp) {
}
static void SetJmp(ThreadState *thr, uptr sp, uptr mangled_sp) {
if (thr->shadow_stack_pos == 0) // called from libc guts during bootstrap
if (!thr->is_inited) // called from libc guts during bootstrap
return;
// Cleanup old bufs.
JmpBufGarbageCollect(thr, sp);
@ -669,9 +669,12 @@ TSAN_INTERCEPTOR(void*, memset, void *dst, int v, uptr size) {
}
TSAN_INTERCEPTOR(void*, memcpy, void *dst, const void *src, uptr size) {
SCOPED_TSAN_INTERCEPTOR(memcpy, dst, src, size);
MemoryAccessRange(thr, pc, (uptr)dst, size, true);
MemoryAccessRange(thr, pc, (uptr)src, size, false);
// On FreeBSD we get here from libthr internals on thread initialization.
if (cur_thread()->is_inited) {
SCOPED_TSAN_INTERCEPTOR(memcpy, dst, src, size);
MemoryAccessRange(thr, pc, (uptr)dst, size, true);
MemoryAccessRange(thr, pc, (uptr)src, size, false);
}
return internal_memcpy(dst, src, size);
}

View File

@ -461,7 +461,7 @@ void GrowShadowStack(ThreadState *thr) {
#endif
u32 CurrentStackId(ThreadState *thr, uptr pc) {
if (thr->shadow_stack_pos == 0) // May happen during bootstrap.
if (!thr->is_inited) // May happen during bootstrap.
return 0;
if (pc != 0) {
#ifndef SANITIZER_GO

View File

@ -371,6 +371,7 @@ struct ThreadState {
const int unique_id;
bool in_symbolizer;
bool in_ignored_lib;
bool is_inited;
bool is_dead;
bool is_freeing;
bool is_vptr_access;

View File

@ -120,6 +120,7 @@ void ThreadContext::OnStarted(void *arg) {
AcquireImpl(thr, 0, &sync);
StatInc(thr, StatSyncAcquire);
sync.Reset(&thr->clock_cache);
thr->is_inited = true;
DPrintf("#%d: ThreadStart epoch=%zu stk_addr=%zx stk_size=%zx "
"tls_addr=%zx tls_size=%zx\n",
tid, (uptr)epoch0, args->stk_addr, args->stk_size,