From 05f841c2211cb69bb1ce556e945d05c1bd3d1065 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Thu, 30 Sep 2021 19:34:39 -0400 Subject: [PATCH] Update references to tsan state The tsan state got moved into the task struct, but references to it were not updated. This fixed the build, though the exectuable itself crashes in LLVM when run. I haven't looked into that yet. --- src/gc-stacks.c | 6 +++--- src/task.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gc-stacks.c b/src/gc-stacks.c index b7adf254026ca..0ac4c6ea0c6d8 100644 --- a/src/gc-stacks.c +++ b/src/gc-stacks.c @@ -234,9 +234,9 @@ void sweep_stack_pools(void) _jl_free_stack(ptls2, stkbuf, bufsz); } #ifdef _COMPILER_TSAN_ENABLED_ - if (t->ctx.tsan_state) { - __tsan_destroy_fiber(t->ctx.tsan_state); - t->ctx.tsan_state = NULL; + if (t->tsan_state) { + __tsan_destroy_fiber(t->tsan_state); + t->tsan_state = NULL; } #endif } diff --git a/src/task.c b/src/task.c index 83b9f048f6462..dd276a9b046c7 100644 --- a/src/task.c +++ b/src/task.c @@ -55,11 +55,11 @@ static inline void sanitizer_finish_switch_fiber(void) {} #endif #if defined(_COMPILER_TSAN_ENABLED_) -static inline void tsan_destroy_ctx(jl_ptls_t ptls, void *state) { - if (state != &ptls->root_task->state) { - __tsan_destroy_fiber(ctx->state); +static inline void tsan_destroy_ctx(jl_ptls_t ptls, void **state) { + if (state != &ptls->root_task->tsan_state) { + __tsan_destroy_fiber(*state); } - ctx->state = NULL; + *state = NULL; } static inline void tsan_switch_to_ctx(void *state) { __tsan_switch_to_fiber(state, 0); @@ -336,7 +336,7 @@ static void ctx_switch(jl_task_t *lastt) assert(ptls->locks.len == 0); #ifdef _COMPILER_TSAN_ENABLED_ - if (lastt->ctx.tsan_state != __tsan_get_current_fiber()) { + if (lastt->tsan_state != __tsan_get_current_fiber()) { // Something went really wrong - don't even assume that we can // use assert/abort which involve lots of signal handling that // looks at the tsan state. @@ -402,7 +402,7 @@ static void ctx_switch(jl_task_t *lastt) jl_set_pgcstack(&t->gcstack); #if defined(_COMPILER_TSAN_ENABLED_) - tsan_switch_to_ctx(&t->tsan_state); + tsan_switch_to_ctx(t->tsan_state); if (killed) tsan_destroy_ctx(ptls, &lastt->tsan_state); #endif