ThreadSanitizer in a Swift Concurrency World

Hi all,

What’s the current status of the thread sanitiser in the concurrency world? There seem to be lots of false positives, both with Swift Concurrency (which shouldn’t be an issue with strict concurrency checking) and the synchronisation framework in it not detecting the usages of Mutex correctly. Where do we report these and is it still a worthwhile tool these days?

Is this on Linux? Thread Sanitizer on macOS seems to work fine for newer deployment targets, I run it with my test suites. That's been the case since a year after concurrency shipped, but like I said, it only works correctly on the newer OS versions. I do wonder if the Linux version still has those original issues.

Yeah this is Linux. I have a project where it throws up false positives around 50% of the time

Not sure why exactly but Thread Sanitiser is often disabled for no obvious reason ("Thread Sanitizer is not available for selected run destination").

Somewhat related "Thread Performance Checker" is crashing every now and then with distinct stack traces.

primarily out of curiosity, do you have any reproductions of this that you could share?

my intuition is that issues should be filed against the compiler repo. IIUC that's were some of the runtime TSAN integration is (e.g. here), as well as the implementations of the Concurrency and Synchronization modules.

1 Like

If you have some reproducers that would probably be a good start, is this Vapor or some project you can't share the sources of?

I haven’t seen false positives & in my experience it generally works well. But I have seen a few compiler crashers over the years, especially when using TSAN with noncopyable types. (E.g. Invalid bitcast in non-copyable struct with pointer and TSAN · Issue #86265 · swiftlang/swift · GitHub in case anyone’s interested in taking a look!)