Bug 58316 - Race condition of threads.c (mono_threads_add_joinable_thread + mono_threads_join_threads)
Summary: Race condition of threads.c (mono_threads_add_joinable_thread + mono_threads_...
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-07-22 17:35 UTC by Armin
Modified: 2017-07-28 18:29 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Stack trace (6.93 KB, text/plain)
2017-07-22 17:35 UTC, Armin

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Armin 2017-07-22 17:35:21 UTC
Created attachment 23735 [details]
Stack trace

Can the following data race be ignored / whitelisted or should the fastpath check be put within the mutex (`joinable_threads_lock ()`) as well? How important is it to detect added threads while running `mono_threads_join_threads ()`? Please find a TSan stack trace attached.

void mono_threads_join_threads (void) {
  // ...
  /* Fastpath */
! if (!joinable_thread_count)
  // ...

void mono_threads_add_joinable_thread (gpointer tid) {
  joinable_threads_lock ();
  // ...
! joinable_thread_count ++;
  // ...
  joinable_threads_unlock ();
  // ...
Comment 1 Armin 2017-07-22 17:36:23 UTC
Sorry, I forgot to tell - last seen with commit 16309a75610232cb0368bcbb99725c2516578949.
Comment 2 Ludovic Henry 2017-07-28 18:29:37 UTC
I think it is ok to whitelist as it's just a fastpath,