← Lessons

quiz vs the machine

Silver1050

Concurrency

Race Condition Detection

How dynamic detectors spot two threads touching the same memory without ordering.

4 min read · intro · beat Silver to climb

What a data race is

A data race happens when two threads access the same memory location, at least one access is a write, and nothing orders the two accesses. The result is undefined and often appears only rarely.

How detection works

A dynamic race detector watches a single real execution and records, for each memory location:

  • which threads read or wrote it
  • what synchronization happened around each access

If it finds two accesses with no ordering between them and one is a write, it reports a race.

Why it misses some bugs

A detector that watches one run only sees the schedule that actually happened. A race on a path that never executed stays hidden, so detection finds bugs but cannot prove their absence.

Key idea

A data race is an unordered conflicting access, and a dynamic detector reports one only when the racing pair actually runs during the observed execution.

Check yourself

Answer to earn rating on the learn ladder.

1. What three conditions define a data race?

2. Why can a dynamic detector miss a real race?