Skip to content

Race Condition

A race condition occurs when program correctness depends on the relative timing of events. The outcome is non-deterministic because the interleaving of operations is not controlled. Data races are a special case where unsynchronized access to the same memory location includes at least one write.

Tension Addressed

Safety vs. Liveness

Recognizable As

"Check-then-act" patterns, "read-modify-write" without atomicity, any assumption that operations will "usually" complete in a certain order. Symptoms include intermittent failures, tests that pass sometimes, bugs that disappear under debugging.

Canonical Sources

Netzer & Miller, "What Are Race Conditions?" (1992); Goetz, "Java Concurrency in Practice" (2006)

Transfers To

Distributed systems (TOCTOU in APIs), file systems (concurrent access), databases (transaction anomalies)