What the sanitizer tracks
A thread sanitizer instruments every memory access at compile time. For each location it keeps a shadow state describing recent accesses and the vector clock of the thread that made them.
Vector clocks order events
A vector clock gives each thread a counter and lets the tool decide whether one access happens before another:
- locks, joins, and atomic operations advance clocks
- if two accesses have incomparable clocks they are concurrent
- a concurrent pair where one writes is a data race
Why it has few false alarms
Because it reasons from real synchronization, the sanitizer reports only genuinely unordered accesses. It still observes a single run, so it can miss races on untaken paths but rarely cries wolf.
Key idea
The thread sanitizer uses vector clocks and shadow memory to decide whether two accesses are ordered, reporting a race only for a truly concurrent conflicting pair.