0

I'm using GCC 9.2 TSan to analyze my codebase's runtime multithreading behavior (using pthreads explicitly -- we started before C++11). I have a data race while a destroyed mutex is held, with the following (relatively unhelpful):

Mutex M974039071667323520 is already destroyed.

And no further information on where this mutex was created or where it was destroyed. TSan reports stack traces of the accessed heap location, where that heap memory was allocated and of the threads' creation, but no stack trace of where the mutexes were destroyed.

I'd like to add some debug output to places where I have possible candidates for these mutexes, but it wouldn't help me if I cannot correlate the debug statement mutex to the reported mutex in any way -- thus the question:

Is there a way to use ThreadSanitizer-reported mutex name M974039071667323520 in my own code?


From what I gathered in about 10min of grepping through gcc's libsanitizers/tsan/ codebase, it seems like an internal counter uid_gen_ is atomically incremented for each SyncVar which would imply that it's a tsan's private value and there's no way to get that value in my code, is this correct?

Irfy
  • 9,323
  • 1
  • 45
  • 67
  • `in my own code` - what mutex implementation are you using in your own code? `pthread_mutex`? – KamilCuk Mar 18 '20 at 11:49
  • Correct, thanks for pointing out the lack of that information, updating. – Irfy Mar 18 '20 at 12:06
  • 1
    Are you on windows or linux? Is there a message above and below the line? [PrintMutex](https://code.woboq.org/gcc/libsanitizer/tsan/tsan_report.cc.html#236) – KamilCuk Mar 18 '20 at 12:08
  • I'm on linux. It's a more-or-less standard data race situation, i.e. I have stack traces of two threads producing the race by accessing a heap location and a stack trace of the allocation of that heap location, as well as a stack trace of the two threads' creation. That is all good, but I cannot deduce where the mutexes were destroyed, since there's no backtrace for that part and it could have happened in many side-paths from the given stack traces, or even in a different thread. I need to figure *that* out. – Irfy Mar 18 '20 at 17:38

0 Answers0