Skip to content

LK4D4/debugmutex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

debugmutex

Build Status GoDoc

Mutex for debugging deadlocks. It can find non-obvious deadlocks in systems with heavy sync.Mutex usage. I found many deadlocks in Docker with it.

Usage

type Struct struct {
    sync.Locker
}

func New() *Struct {
    locker := &sync.Mutex{}
    if os.Getenv("DEBUG") != "" {
        // will crash program with traceback and file:line where deadlock is
        // occured after five tries to acquire mutex with 1 second gap between.
        locker = debugmutex.New(5, true)
    }
    return &Struct{Locker: locker}
}

For logging github.com/sirupsen/logrus is used. You can set debug logging with

logrus.SetLevel(logrus.DebugLevel)

About

Mutex for debugging deadlocks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages