IT lexicon › Security › Data race

Data race

Security På svenska → Updated: 2026-11-15

When two threads access the same memory location without synchronization, one writing, producing undefined behavior.

A data race is different from a race condition (which may cause logical errors). In a data race, the compiler makes no guarantees about behavior—it may generate incorrect code, silently corrupt memory, or exhibit different behavior on different runs or optimizations. C++ and Rust treat data races seriously: Rust forbids them via compile-time checks, while C++ requires tool support like thread sanitizers to catch them at runtime.

← Back to the lexicon