Go's Race Detector: A Mutex Blind Spot

2025-07-31
Go's Race Detector: A Mutex Blind Spot

Go's race detector has a blind spot when dealing with mutexes. An example demonstrates how two goroutines using a mutex to protect a shared counter, with one performing an additional increment outside the lock. Even though a data race is possible, Go's detector might miss it because it relies on the order of lock acquisition, which is unpredictable at runtime. While Go's race detector is a best-in-class tool, this example highlights that race conditions can still exist even when the detector reports no races.

Read more
Development race detection