5. Detection of data-races and atomicity violations

A race condition is a situation in which acccesses to a data item in two threads or processes do not have a precedence relation between them, and at least one of them is a write access. It may cause unexpected values to be assigned to the data item, which, in turn, may cause incorrect results in the program.

In trace-based race analysis, the program is executed and significant events occuring during the execution are recorded in the form of a trace. The trace is later analysed to determine whether a race condition had occurred during that execution of the program.

Two myths about race detection are prevelant:

1. For detecting all races in a program, one must consider all possible interleavings of code in different threads.
2. One must use a vector clock with a component for each thread for determining whether accesses to a shared variable in different threads have occurred in parallel.

These myths lead to significant overhead in trace-based race analysis. We formulate a unified approach to race detection which explodes these two myths and eliminates their consequences on efficiency. This approach can also be applied to detection of atomicity violations in programs.