Creative foot-shooting with Go RWMutex
Oct 29, 2015Filippo Valsorda

Summary
This post details a bug in the Go RWMutex implementation within Cloudflare's RRDNS server. A background goroutine periodically reloaded an IP table, acquiring a write lock. A consumer function used read locks. When the table reload function ran while queries were being processed, its pending write lock call blocked subsequent read lock calls, causing a deadlock. This highlights a subtle concurrency bug where a blocked Lock call can prevent new readers from acquiring the RLock, leading to a deferred deadlock. The post suggests improvements in tooling for static and dynamic analysis of mutex usage.
More from the DNS Infrastructure & Naming Conventions trail
- The keys to the Internet change on October 11, 2026. Are you ready?
- 1.1.1.1 now supports post-quantum DNSSEC, all 2,420 bytes of it
- How we saved 100 terabytes of memory by optimizing 1.1.1.1’s DNS cache
- BGP ORIGIN attribute manipulation and its impact on the Internet
- Cloudflare Internal DNS is now generally available