tsan: handle early signals

The second part of the fix of
https://code.google.com/p/thread-sanitizer/issues/detail?id=71

llvm-svn: 217031
This commit is contained in:
Dmitry Vyukov 2014-09-03 12:25:22 +00:00
parent f1741f52ad
commit f8cfdd9207
4 changed files with 3 additions and 5 deletions

View File

@ -151,7 +151,7 @@ void InitializeLibIgnore() {
static SignalContext *SigCtx(ThreadState *thr) {
SignalContext *ctx = (SignalContext*)thr->signal_ctx;
if (ctx == 0 && thr->is_alive) {
if (ctx == 0 && !thr->is_dead) {
ctx = (SignalContext*)MmapOrDie(sizeof(*ctx), "SignalContext");
MemoryResetRange(thr, (uptr)&SigCtx, (uptr)ctx, sizeof(*ctx));
thr->signal_ctx = ctx;

View File

@ -356,7 +356,7 @@ struct ThreadState {
const int unique_id;
bool in_symbolizer;
bool in_ignored_lib;
bool is_alive;
bool is_dead;
bool is_freeing;
bool is_vptr_access;
const uptr stk_addr;

View File

@ -123,7 +123,6 @@ void ThreadContext::OnStarted(void *arg) {
"tls_addr=%zx tls_size=%zx\n",
tid, (uptr)epoch0, args->stk_addr, args->stk_size,
args->tls_addr, args->tls_size);
thr->is_alive = true;
}
void ThreadContext::OnFinished() {
@ -284,7 +283,7 @@ void ThreadFinish(ThreadState *thr) {
DontNeedShadowFor(thr->stk_addr, thr->stk_size);
if (thr->tls_addr && thr->tls_size)
DontNeedShadowFor(thr->tls_addr, thr->tls_size);
thr->is_alive = false;
thr->is_dead = true;
ctx->thread_registry->FinishThread(thr->tid);
}

View File

@ -119,7 +119,6 @@ int main(int argc, const char *argv[]) {
Init();
pthread_t busy_thread;
pthread_create(&busy_thread, NULL, &BusyThread, NULL);
sleep(1); // Tsan deadlocks without these sleeps
CollectGarbage(busy_thread);
pthread_join(busy_thread, 0);
fprintf(stderr, "DONE\n");