Workaround TSan hang in free_inner when called from at-fork child handler
authorIvan Maidanski <ivmai@mail.ru>
Fri, 15 Dec 2017 07:15:05 +0000 (10:15 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 15 Dec 2017 07:15:05 +0000 (10:15 +0300)
* 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

index ae262fd..bb8a0d5 100644 (file)
@@ -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);