Skip to content
uencoder

Data Race

A data race occurs when multiple threads read and write the same location concurrently, with at least one write and no synchronization, causing undefined behavior.

Purpose

To understand the undefined behavior caused by data races and their defenses; a core concern of concurrent-program correctness.

Mechanism

Thread A writes x while thread B reads/writes x without synchronization; the result is indeterminate (torn values, partial writes). In C/C++ a data race is undefined behavior. Defenses: mutexes, atomic operations, memory barriers.

Use cases

  • Concurrency correctness analysis
  • Thread safety audit
  • Data race detection

Related tools

References