From 8ea3bd8c89f6d0ec3a9f341826ee1a67a0d7b154 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Fri, 17 Mar 2023 18:11:48 +0000 Subject: [PATCH] Prevent thread leak warning with tsan --- src/thread.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/thread.c b/src/thread.c index 686da711..f43cc8af 100644 --- a/src/thread.c +++ b/src/thread.c @@ -467,9 +467,6 @@ static void *thread_wrapper(void *arg) // Avoid races with stop_world SCOPED_LOCK(stop_lock); - assert(threads[my_thread->id] == my_thread); - atomic_store(&(threads[my_thread->id]), NULL); - atomic_add(&running_threads, -1); return result; } @@ -504,6 +501,9 @@ void *thread_join(nvc_thread_t *thread) void *retval = NULL; PTHREAD_CHECK(pthread_join, thread->handle, &retval); + assert(threads[thread->id] == thread); + atomic_store(&(threads[thread->id]), NULL); + async_free(thread->name); async_free(thread); -- 2.39.2