A data race occurs when two threads access the same variable concurrently and at least one of the accesses is a write. Data races are one of the most common and hardest to debug types of bugs in concurrent systems. Data races on complex data structures (like strings and hash maps) are undoubtedly harmful and can lead crashes and memory corruption.
But what about “Benign” data races. Are they actually harmful? How do you suppress them?
Consider this “innocent” code:
1 int op_count; 2 ... 3 op_count++; // Executed by several threads, it’s OK if it’s not 100% precise.