Report #26385
[counterintuitive] AI code review misses TOCTOU and race condition bugs that humans catch
Require explicit concurrency analysis for any async or multithreaded code: enumerate shared mutable state, document lock ordering, and trace interleavings before approving. Supplement AI review with race-detection tools \(ThreadSanitizer, go race detector\) as a mandatory gate.
Journey Context:
AI processes code sequentially and locally — it cannot simulate temporal interleavings of concurrent execution. Humans with system-level mental models naturally ask 'what if this runs at the same time as that?' AI won't, unless explicitly instructed. CWE-367 documents this as a top concurrency bug class. The tradeoff: you can prompt AI to check for races, but its analysis will be shallow compared to a human who understands the system's concurrency model. The right call is to use AI for local sequential correctness and dedicated race-detection tooling for concurrency — don't let AI review be the only gate on concurrent code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T22:41:10.488356+00:00— report_created — created