{"repo":"sasha-s/go-deadlock","free":true,"listed":false,"github":"https://github.com/sasha-s/go-deadlock","clone":"git clone https://github.com/sasha-s/go-deadlock.git","description":"Online deadlock detection in go (golang)","language":"Go","stars":1191,"topics":["deadlock","golang","mutex","online-deadlock-detection"],"license":"Apache-2.0","category":"dev-tools","readme_excerpt":"Online deadlock detection in go (golang). Why Deadlocks happen and are painful to debug. What go-deadlock provides (RW)Mutex drop-in replacements for sync.(RW)Mutex. It would not work if you create a spaghetti of channels. Mutexes only. Installation Usage Deadlocks One of the most common sources of deadlocks is inconsistent lock ordering: say, you have two mutexes A and B, and in some goroutines you have And in another goroutine the order of locks is reversed: Another common sources of deadlocks is duplicate take a lock in a goroutine: This does not guarantee a deadlock (maybe the goroutines above can never be running at the same time), but it usually a design flaw at least. go-deadlock can detect such cases (unless you cross goroutine boundary - say lock A, then spawn a goroutine, block until it is singals, and lock B inside of the goroutine), even if the deadlock itself happens very infrequently and is painful to reproduce! Each time go-deadlock sees a lock attempt for lock B, it records the order A before B, for each lock that is currently being held in the same goroutine, and it prints (and exits the program by default) when it sees the locking order being violated. In addition, if it sees that we are waiting on a lock for a long time (opts.DeadlockTimeout, 30 seconds by default), it reports a potential deadlock, also printing the stacktrace for a goroutine that is currently holding the lock we are desperately trying to grab. Sample output Inconsistent lock ordering: Wait","default_branch":null,"files":null,"tree":[],"storefront":"/r/sasha-s","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/sasha-s/go-deadlock/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}