Thread Sanitizer can use suppression files to selectively turn off reporting for problems it detects in libraries outside of your code. To use these with Xcode, first create a file named TSan.supp
(or something similar) and put lines into it like the following:
mutex:Purge
mutex:ProcessBulkInData
mutex:EventDestroy
I was encountering issues with bad mutexes in several internal functions within a particular library, so I suppressed the mutex warnings (the mutex:
part of the above) by providing a substring from the function names that appeared in the Thread Sanitizer stack trace.
Once you have the suppression file done, edit your Run scheme in Xcode and go to the Arguments tab. Under Environment Variables, add the name TSAN_OPTIONS
and give it a value of suppressions=[path_to_TSan.supp]
. The path will need to be relative to your application's binary file in your derived data location.
You may need to run Thread Sanitizer a few times and edit your suppression file to add each of the items from the library you wish to suppress.
The file format and other options of this suppression file can be found on this wiki page. For posterity, these are
thread: suppresses reports related to threads (leaks)
mutex: suppresses reports related to mutexes (destruction of a locked mutex)
signal: suppresses reports related to signal handlers (handler calls malloc())
deadlock: suppresses lock inversion reports
called_from_lib: suppresses all interceptors in a particular library
Thanks go to the anonymous Apple engineer who explained this process in response to a recent bug report.