This talk is about ThreadSanitizer internals. It will discuss the data structures, algorithms and memory model theoretical foundations that ThreadSanitizer use to detect data races and deadlocks in multi-threaded programs.
Data race is a common issue when dealing with multi-threaded program. Because data race happened randomly, it’s hard to detect data races in testing phase without help from good tools. Theoretically, if there are no memory and computational power limit, it’s possible to detect data races by monitoring all operations related to shared variables. ThreadSanitizer is designed to detect data races in complicated program like Chrome in real world. In this talk, I will introduce the algorithms, data structures and trade-offs of ThreadSanitizer and walk the audience through the source code of both the compiler instrumentation and the runtime library.