An Extremely Simplified Implementation of Thread Sanitizer's Data Race Detection in Swift
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
DataRaceDetector.xcodeproj
DataRaceDetector
DataRaceDetectorTests
.gitignore
LICENSE.MD
README.md Add Blog Post Link Nov 18, 2016

README.md

This is an educational project that I undertook to learn more about Thread Sanitizer. You can read about the context of this project in this blog post.

Data Race Detector in Swift

This is a project I undertook for educational purposes. It aims to implement the algorithm of the data race detection in LLVM's Thread Sanitizer in Swift.

While the actual Thread Sanitizer uses compile time instrumentation and a runtime library, this toy project is entirely implemented in Swift. To make this possible, the implementation provides an ObservedValue<T> type in which a value needs to be wrapped in order to be monitored for potential data races.

Additionally the libary provides its own mutex via the function synchronized. The data race detector only understands synchronization that happens through that function; synchronization by any other means cannot be tracked and will therefore lead to incorrectly reported data races.

Here's the Google Research paper that describes the algorithm for data race detection in Thread Sanitizer and here's an Apple WWDC 2016 session that discusses the algorithm as well.