From 15be5550428692304d0f35c62145030d17fc3b1b Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 15 Dec 2017 10:15:05 +0300 Subject: [PATCH] Workaround TSan hang in free_inner when called from at-fork child handler * pthread_support.c [CAN_HANDLE_FORK] (GC_remove_all_threads_but_me): Do not call GC_INTERNAL_FREE(p) if THREAD_SANITIZER and CAN_CALL_ATFORK; add comment. --- pthread_support.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pthread_support.c b/pthread_support.c index ae262fd..bb8a0d5 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -801,7 +801,11 @@ STATIC void GC_remove_all_threads_but_me(void) GC_remove_specific_after_fork(GC_thread_key, p -> id); } # endif - if (p != &first_thread) GC_INTERNAL_FREE(p); + /* TODO: To avoid TSan hang (when updating GC_bytes_freed), */ + /* we just skip explicit freeing of GC_threads entries. */ +# if !defined(THREAD_SANITIZER) || !defined(CAN_CALL_ATFORK) + if (p != &first_thread) GC_INTERNAL_FREE(p); +# endif } } store_to_threads_table(hv, me); -- 2.7.4