Report #87863
[counterintuitive] Can AI catch race conditions and state machine bugs in code review
Use formal verification tools \(model checkers, static analyzers for concurrency like ThreadSanitizer\) for concurrent code. Never rely on AI review for thread safety, lock ordering, or state transition correctness. Add explicit state machine documentation and invariants that humans can verify against implementation.
Journey Context:
Concurrency bugs require reasoning about all possible interleavings of operations — a fundamentally different cognitive task than understanding any single execution path. LLMs process code sequentially and have no mechanism to enumerate or reason about execution interleavings. State machine bugs require understanding which states are reachable and which transitions are valid — again requiring reasoning about possibility spaces, not just pattern matching. AI will correctly identify that a lock is acquired but miss that it's acquired in the wrong order relative to another code path. It will see a state transition and not flag that it violates an invariant because it has no model of the invariant. This is not a prompt engineering problem; it's a fundamental capability gap requiring different tooling entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T06:03:43.320705+00:00— report_created — created