Memory Race Condition

Detects concurrent memory access without proper synchronization in C/C++ and Go programs.

zakirkun f4cf94a 2 files · 1.8 KB Updated

File contents

Memory Race Condition

Overview

Memory race conditions occur when two threads access shared memory simultaneously without synchronization, and at least one access is a write. This leads to:

  • Data corruption (non-deterministic results)
  • Security bypass (auth state race)
  • Potential exploitation via crafted timing

Remediation

  • Use mutex/lock primitives for all shared data access
  • Use atomic operations for simple counters and flags
  • Design for lock-free or copy-on-write patterns where performance matters
  • Use Go race detector: go test -race

zakirkun/ice-tea/tree/main/skills/memory/race-condition-memory commit f4cf94abfa

Frequently asked questions

npx skillmds@latest add zakirkun/memory-race-condition