Skip to content

Commit f8cfdd9

Browse files
committed
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
1 parent f1741f5 commit f8cfdd9

File tree

4 files changed

+3
-5
lines changed

4 files changed

+3
-5
lines changed

compiler-rt/lib/tsan/rtl/tsan_interceptors.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void InitializeLibIgnore() {
151151

152152
static SignalContext *SigCtx(ThreadState *thr) {
153153
SignalContext *ctx = (SignalContext*)thr->signal_ctx;
154-
if (ctx == 0 && thr->is_alive) {
154+
if (ctx == 0 && !thr->is_dead) {
155155
ctx = (SignalContext*)MmapOrDie(sizeof(*ctx), "SignalContext");
156156
MemoryResetRange(thr, (uptr)&SigCtx, (uptr)ctx, sizeof(*ctx));
157157
thr->signal_ctx = ctx;

compiler-rt/lib/tsan/rtl/tsan_rtl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ struct ThreadState {
356356
const int unique_id;
357357
bool in_symbolizer;
358358
bool in_ignored_lib;
359-
bool is_alive;
359+
bool is_dead;
360360
bool is_freeing;
361361
bool is_vptr_access;
362362
const uptr stk_addr;

compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ void ThreadContext::OnStarted(void *arg) {
123123
"tls_addr=%zx tls_size=%zx\n",
124124
tid, (uptr)epoch0, args->stk_addr, args->stk_size,
125125
args->tls_addr, args->tls_size);
126-
thr->is_alive = true;
127126
}
128127

129128
void ThreadContext::OnFinished() {
@@ -284,7 +283,7 @@ void ThreadFinish(ThreadState *thr) {
284283
DontNeedShadowFor(thr->stk_addr, thr->stk_size);
285284
if (thr->tls_addr && thr->tls_size)
286285
DontNeedShadowFor(thr->tls_addr, thr->tls_size);
287-
thr->is_alive = false;
286+
thr->is_dead = true;
288287
ctx->thread_registry->FinishThread(thr->tid);
289288
}
290289

compiler-rt/test/tsan/signal_recursive.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ int main(int argc, const char *argv[]) {
119119
Init();
120120
pthread_t busy_thread;
121121
pthread_create(&busy_thread, NULL, &BusyThread, NULL);
122-
sleep(1); // Tsan deadlocks without these sleeps
123122
CollectGarbage(busy_thread);
124123
pthread_join(busy_thread, 0);
125124
fprintf(stderr, "DONE\n");

0 commit comments

Comments
 (0)