By George Aristy / llorllale
nil
channel .
package main
import "sync"
func main() {
muA := sync.Mutex{}
muB := sync.Mutex{}
// main goroutine acquires both locks
muA.Lock()
muB.Lock()
// first sub goroutine attempts to lock "B" before releasing "A".
go func() {
defer muA.Unlock()
muB.Lock()
}()
// second sub goroutine attempts to lock "A" before releasing "B".
go func() { // second sub goroutine
defer muB.Unlock()
muA.Lock()
}()
// third sub goroutine attempts to read from an empty channel that is never written to
go func() {
empty := make(chan struct{})
<-empty
}()
// fourth sub goroutine attempts to read from a nil channel
go func() {
var c chan struct{}
<-c
}()
// main goroutine blocked trying to write to an unbuffered channel
make(chan struct{}) <- struct{}{}
}
package main
import "sync"
func main() {
muA := sync.Mutex{}
muB := sync.Mutex{}
// main goroutine acquires both locks
muA.Lock()
muB.Lock()
// first sub goroutine attempts to lock "B" before releasing "A".
go func() {
defer muA.Unlock()
muB.Lock()
}()
// second sub goroutine attempts to lock "A" before releasing "B".
go func() { // second sub goroutine
defer muB.Unlock()
muA.Lock()
}()
// third sub goroutine attempts to read from an empty channel that is never written to
go func() {
empty := make(chan struct{})
<-empty
}()
// fourth sub goroutine attempts to read from a nil channel
go func() {
var c chan struct{}
<-c
}()
// main goroutine blocked trying to write to an unbuffered channel
make(chan struct{}) <- struct{}{}
}
package main
import "sync"
func main() {
muA := sync.Mutex{}
muB := sync.Mutex{}
// main goroutine acquires both locks
muA.Lock()
muB.Lock()
// first sub goroutine attempts to lock "B" before releasing "A".
go func() {
defer muA.Unlock()
muB.Lock()
}()
// second sub goroutine attempts to lock "A" before releasing "B".
go func() { // second sub goroutine
defer muB.Unlock()
muA.Lock()
}()
// third sub goroutine attempts to read from an empty channel that is never written to
go func() {
empty := make(chan struct{})
<-empty
}()
// fourth sub goroutine attempts to read from a nil channel
go func() {
var c chan struct{}
<-c
}()
// main goroutine blocked trying to write to an unbuffered channel
make(chan struct{}) <- struct{}{}
}
package main
import "sync"
func main() {
muA := sync.Mutex{}
muB := sync.Mutex{}
// main goroutine acquires both locks
muA.Lock()
muB.Lock()
// first sub goroutine attempts to lock "B" before releasing "A".
go func() {
defer muA.Unlock()
muB.Lock()
}()
// second sub goroutine attempts to lock "A" before releasing "B".
go func() { // second sub goroutine
defer muB.Unlock()
muA.Lock()
}()
// third sub goroutine attempts to read from an empty channel that is never written to
go func() {
empty := make(chan struct{})
<-empty
}()
// fourth sub goroutine attempts to read from a nil channel
go func() {
var c chan struct{}
<-c
}()
// main goroutine blocked trying to write to an unbuffered channel
make(chan struct{}) <- struct{}{}
}
package main
import "sync"
func main() {
muA := sync.Mutex{}
muB := sync.Mutex{}
// main goroutine acquires both locks
muA.Lock()
muB.Lock()
// first sub goroutine attempts to lock "B" before releasing "A".
go func() {
defer muA.Unlock()
muB.Lock()
}()
// second sub goroutine attempts to lock "A" before releasing "B".
go func() { // second sub goroutine
defer muB.Unlock()
muA.Lock()
}()
// third sub goroutine attempts to read from an empty channel that is never written to
go func() {
empty := make(chan struct{})
<-empty
}()
// fourth sub goroutine attempts to read from a nil channel
go func() {
var c chan struct{}
<-c
}()
// main goroutine blocked trying to write to an unbuffered channel
make(chan struct{}) <- struct{}{}
}
package main
import "sync"
func main() {
muA := sync.Mutex{}
muB := sync.Mutex{}
// main goroutine acquires both locks
muA.Lock()
muB.Lock()
// first sub goroutine attempts to lock "B" before releasing "A".
go func() {
defer muA.Unlock()
muB.Lock()
}()
// second sub goroutine attempts to lock "A" before releasing "B".
go func() { // second sub goroutine
defer muB.Unlock()
muA.Lock()
}()
// third sub goroutine attempts to read from an empty channel that is never written to
go func() {
empty := make(chan struct{})
<-empty
}()
// fourth sub goroutine attempts to read from a nil channel
go func() {
var c chan struct{}
<-c
}()
// main goroutine blocked trying to write to an unbuffered channel
make(chan struct{}) <- struct{}{}
}
package main
import "sync"
func main() {
muA := sync.Mutex{}
muB := sync.Mutex{}
// main goroutine acquires both locks
muA.Lock()
muB.Lock()
// first sub goroutine attempts to lock "B" before releasing "A".
go func() {
defer muA.Unlock()
muB.Lock()
}()
// second sub goroutine attempts to lock "A" before releasing "B".
go func() { // second sub goroutine
defer muB.Unlock()
muA.Lock()
}()
// third sub goroutine attempts to read from an empty channel that is never written to
go func() {
empty := make(chan struct{})
<-empty
}()
// fourth sub goroutine attempts to read from a nil channel
go func() {
var c chan struct{}
<-c
}()
// main goroutine blocked trying to write to an unbuffered channel
make(chan struct{}) <- struct{}{}
}
fatal error: all goroutines are asleep - deadlock!
goroutine 1 [chan send]:
main.main()
/home/llorllale/scratchpad/main.go:38 +0x169
goroutine 6 [semacquire]:
sync.runtime_SemacquireMutex(0x0?, 0x0?, 0x0?)
/home/llorllale/.gvm/gos/go1.19/src/runtime/sema.go:77 +0x25
sync.(*Mutex).lockSlow(0xc0000220a0)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:171 +0x165
sync.(*Mutex).Lock(...)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:90
main.main.func1()
/home/llorllale/scratchpad/main.go:16 +0x72
created by main.main
/home/llorllale/scratchpad/main.go:14 +0xe5
goroutine 7 [semacquire]:
sync.runtime_SemacquireMutex(0x0?, 0x0?, 0x0?)
/home/llorllale/.gvm/gos/go1.19/src/runtime/sema.go:77 +0x25
sync.(*Mutex).lockSlow(0xc000022098)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:171 +0x165
sync.(*Mutex).Lock(...)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:90
main.main.func2()
/home/llorllale/scratchpad/main.go:22 +0x72
created by main.main
/home/llorllale/scratchpad/main.go:20 +0x139
goroutine 8 [chan receive]:
main.main.func3()
/home/llorllale/scratchpad/main.go:28 +0x2c
created by main.main
/home/llorllale/scratchpad/main.go:26 +0x145
goroutine 9 [chan receive (nil chan)]:
main.main.func4()
/home/llorllale/scratchpad/main.go:34 +0x1d
created by main.main
/home/llorllale/scratchpad/main.go:32 +0x151
fatal error: all goroutines are asleep - deadlock!
goroutine 1 [chan send]:
main.main()
/home/llorllale/scratchpad/main.go:38 +0x169
goroutine 6 [semacquire]:
sync.runtime_SemacquireMutex(0x0?, 0x0?, 0x0?)
/home/llorllale/.gvm/gos/go1.19/src/runtime/sema.go:77 +0x25
sync.(*Mutex).lockSlow(0xc0000220a0)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:171 +0x165
sync.(*Mutex).Lock(...)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:90
main.main.func1()
/home/llorllale/scratchpad/main.go:16 +0x72
created by main.main
/home/llorllale/scratchpad/main.go:14 +0xe5
goroutine 7 [semacquire]:
sync.runtime_SemacquireMutex(0x0?, 0x0?, 0x0?)
/home/llorllale/.gvm/gos/go1.19/src/runtime/sema.go:77 +0x25
sync.(*Mutex).lockSlow(0xc000022098)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:171 +0x165
sync.(*Mutex).Lock(...)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:90
main.main.func2()
/home/llorllale/scratchpad/main.go:22 +0x72
created by main.main
/home/llorllale/scratchpad/main.go:20 +0x139
goroutine 8 [chan receive]:
main.main.func3()
/home/llorllale/scratchpad/main.go:28 +0x2c
created by main.main
/home/llorllale/scratchpad/main.go:26 +0x145
goroutine 9 [chan receive (nil chan)]:
main.main.func4()
/home/llorllale/scratchpad/main.go:34 +0x1d
created by main.main
/home/llorllale/scratchpad/main.go:32 +0x151
main
goroutine is blocked trying to send to a channel:
fatal error: all goroutines are asleep - deadlock!
goroutine 1 [chan send]:
main.main()
/home/llorllale/scratchpad/main.go:38 +0x169
goroutine 6 [semacquire]:
sync.runtime_SemacquireMutex(0x0?, 0x0?, 0x0?)
/home/llorllale/.gvm/gos/go1.19/src/runtime/sema.go:77 +0x25
sync.(*Mutex).lockSlow(0xc0000220a0)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:171 +0x165
sync.(*Mutex).Lock(...)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:90
main.main.func1()
/home/llorllale/scratchpad/main.go:16 +0x72
created by main.main
/home/llorllale/scratchpad/main.go:14 +0xe5
goroutine 7 [semacquire]:
sync.runtime_SemacquireMutex(0x0?, 0x0?, 0x0?)
/home/llorllale/.gvm/gos/go1.19/src/runtime/sema.go:77 +0x25
sync.(*Mutex).lockSlow(0xc000022098)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:171 +0x165
sync.(*Mutex).Lock(...)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:90
main.main.func2()
/home/llorllale/scratchpad/main.go:22 +0x72
created by main.main
/home/llorllale/scratchpad/main.go:20 +0x139
goroutine 8 [chan receive]:
main.main.func3()
/home/llorllale/scratchpad/main.go:28 +0x2c
created by main.main
/home/llorllale/scratchpad/main.go:26 +0x145
goroutine 9 [chan receive (nil chan)]:
main.main.func4()
/home/llorllale/scratchpad/main.go:34 +0x1d
created by main.main
/home/llorllale/scratchpad/main.go:32 +0x151
first
sub goroutine is blocked trying to acquire a lock:
fatal error: all goroutines are asleep - deadlock!
goroutine 1 [chan send]:
main.main()
/home/llorllale/scratchpad/main.go:38 +0x169
goroutine 6 [semacquire]:
sync.runtime_SemacquireMutex(0x0?, 0x0?, 0x0?)
/home/llorllale/.gvm/gos/go1.19/src/runtime/sema.go:77 +0x25
sync.(*Mutex).lockSlow(0xc0000220a0)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:171 +0x165
sync.(*Mutex).Lock(...)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:90
main.main.func1()
/home/llorllale/scratchpad/main.go:16 +0x72
created by main.main
/home/llorllale/scratchpad/main.go:14 +0xe5
goroutine 7 [semacquire]:
sync.runtime_SemacquireMutex(0x0?, 0x0?, 0x0?)
/home/llorllale/.gvm/gos/go1.19/src/runtime/sema.go:77 +0x25
sync.(*Mutex).lockSlow(0xc000022098)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:171 +0x165
sync.(*Mutex).Lock(...)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:90
main.main.func2()
/home/llorllale/scratchpad/main.go:22 +0x72
created by main.main
/home/llorllale/scratchpad/main.go:20 +0x139
goroutine 8 [chan receive]:
main.main.func3()
/home/llorllale/scratchpad/main.go:28 +0x2c
created by main.main
/home/llorllale/scratchpad/main.go:26 +0x145
goroutine 9 [chan receive (nil chan)]:
main.main.func4()
/home/llorllale/scratchpad/main.go:34 +0x1d
created by main.main
/home/llorllale/scratchpad/main.go:32 +0x151
second
sub goroutine is blocked trying to acquire a lock:
fatal error: all goroutines are asleep - deadlock!
goroutine 1 [chan send]:
main.main()
/home/llorllale/scratchpad/main.go:38 +0x169
goroutine 6 [semacquire]:
sync.runtime_SemacquireMutex(0x0?, 0x0?, 0x0?)
/home/llorllale/.gvm/gos/go1.19/src/runtime/sema.go:77 +0x25
sync.(*Mutex).lockSlow(0xc0000220a0)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:171 +0x165
sync.(*Mutex).Lock(...)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:90
main.main.func1()
/home/llorllale/scratchpad/main.go:16 +0x72
created by main.main
/home/llorllale/scratchpad/main.go:14 +0xe5
goroutine 7 [semacquire]:
sync.runtime_SemacquireMutex(0x0?, 0x0?, 0x0?)
/home/llorllale/.gvm/gos/go1.19/src/runtime/sema.go:77 +0x25
sync.(*Mutex).lockSlow(0xc000022098)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:171 +0x165
sync.(*Mutex).Lock(...)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:90
main.main.func2()
/home/llorllale/scratchpad/main.go:22 +0x72
created by main.main
/home/llorllale/scratchpad/main.go:20 +0x139
goroutine 8 [chan receive]:
main.main.func3()
/home/llorllale/scratchpad/main.go:28 +0x2c
created by main.main
/home/llorllale/scratchpad/main.go:26 +0x145
goroutine 9 [chan receive (nil chan)]:
main.main.func4()
/home/llorllale/scratchpad/main.go:34 +0x1d
created by main.main
/home/llorllale/scratchpad/main.go:32 +0x151
third
sub goroutine is stuck waiting to receive on a channel:
fatal error: all goroutines are asleep - deadlock!
goroutine 1 [chan send]:
main.main()
/home/llorllale/scratchpad/main.go:38 +0x169
goroutine 6 [semacquire]:
sync.runtime_SemacquireMutex(0x0?, 0x0?, 0x0?)
/home/llorllale/.gvm/gos/go1.19/src/runtime/sema.go:77 +0x25
sync.(*Mutex).lockSlow(0xc0000220a0)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:171 +0x165
sync.(*Mutex).Lock(...)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:90
main.main.func1()
/home/llorllale/scratchpad/main.go:16 +0x72
created by main.main
/home/llorllale/scratchpad/main.go:14 +0xe5
goroutine 7 [semacquire]:
sync.runtime_SemacquireMutex(0x0?, 0x0?, 0x0?)
/home/llorllale/.gvm/gos/go1.19/src/runtime/sema.go:77 +0x25
sync.(*Mutex).lockSlow(0xc000022098)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:171 +0x165
sync.(*Mutex).Lock(...)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:90
main.main.func2()
/home/llorllale/scratchpad/main.go:22 +0x72
created by main.main
/home/llorllale/scratchpad/main.go:20 +0x139
goroutine 8 [chan receive]:
main.main.func3()
/home/llorllale/scratchpad/main.go:28 +0x2c
created by main.main
/home/llorllale/scratchpad/main.go:26 +0x145
goroutine 9 [chan receive (nil chan)]:
main.main.func4()
/home/llorllale/scratchpad/main.go:34 +0x1d
created by main.main
/home/llorllale/scratchpad/main.go:32 +0x151
fourth
sub goroutine is stuck waiting to receive on a nil
channel:
fatal error: all goroutines are asleep - deadlock!
goroutine 1 [chan send]:
main.main()
/home/llorllale/scratchpad/main.go:38 +0x169
goroutine 6 [semacquire]:
sync.runtime_SemacquireMutex(0x0?, 0x0?, 0x0?)
/home/llorllale/.gvm/gos/go1.19/src/runtime/sema.go:77 +0x25
sync.(*Mutex).lockSlow(0xc0000220a0)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:171 +0x165
sync.(*Mutex).Lock(...)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:90
main.main.func1()
/home/llorllale/scratchpad/main.go:16 +0x72
created by main.main
/home/llorllale/scratchpad/main.go:14 +0xe5
goroutine 7 [semacquire]:
sync.runtime_SemacquireMutex(0x0?, 0x0?, 0x0?)
/home/llorllale/.gvm/gos/go1.19/src/runtime/sema.go:77 +0x25
sync.(*Mutex).lockSlow(0xc000022098)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:171 +0x165
sync.(*Mutex).Lock(...)
/home/llorllale/.gvm/gos/go1.19/src/sync/mutex.go:90
main.main.func2()
/home/llorllale/scratchpad/main.go:22 +0x72
created by main.main
/home/llorllale/scratchpad/main.go:20 +0x139
goroutine 8 [chan receive]:
main.main.func3()
/home/llorllale/scratchpad/main.go:28 +0x2c
created by main.main
/home/llorllale/scratchpad/main.go:26 +0x145
goroutine 9 [chan receive (nil chan)]:
main.main.func4()
/home/llorllale/scratchpad/main.go:34 +0x1d
created by main.main
/home/llorllale/scratchpad/main.go:32 +0x151
goroutine 21 [chan receive (nil chan)]: <=== wait reason
main.main.func4(0x0?)
/home/llorllale/scratchpad/main.go:34 +0x1b
created by main.main
/home/llorllale/scratchpad/main.go:33 +0x173
Wait reasons .
goroutine 21 [chan receive (nil chan)]:
main.main.func4(0x0?) <=== FQN of func + args
/home/llorllale/scratchpad/main.go:34 +0x1b <=== file + line no.
created by main.main
/home/llorllale/scratchpad/main.go:33 +0x173
goroutine 21 [chan receive (nil chan)]:
main.main.func4(0x0?)
/home/llorllale/scratchpad/main.go:34 +0x1b
created by main.main <=== ancestor
/home/llorllale/scratchpad/main.go:33 +0x173 <=== ancestor definition
"fatal error: all goroutines are asleep - deadlock!"
- Go runtimewget -O trace.out http://localhost:6060/debug/pprof/trace?seconds=5
wget -O trace.out http://localhost:6060/debug/pprof/trace?seconds=5
go tool trace ./trace.out
wget -O profile.out http://localhost:6060/debug/pprof/profile?seconds=5
wget -O profile.out http://localhost:6060/debug/pprof/profile?seconds=5
go tool pprof ./profile.out
package main
import (
sync "github.com/sasha-s/go-deadlock"
"time"
)
func main() {
sync.Opts.DeadlockTimeout = time.Second
var A sync.Mutex
var B sync.Mutex
A.Lock()
B.Lock()
go func() {
defer A.Unlock()
B.Lock()
}()
go func() {
defer B.Unlock()
A.Lock()
}()
for {
time.Sleep(time.Second)
}
}
POTENTIAL DEADLOCK:
Previous place where the lock was grabbed
goroutine 1 lock 0xc000022090
sasha-deadlock/main.go:16 main.main { } <<<<<
~/go/pkg/mod/github.com/sasha-s/go-deadlock@v0.3.1/deadlock.go:84 go-deadlock.(*Mutex).Lock { func (m *Mutex) Lock() { }
~/.gvm/gos/go1.19/src/runtime/proc.go:258 runtime.main { // Once it does, it will exit. See issues 3934 and 20018. }
Have been trying to lock it again for more than 1s
goroutine 8 lock 0xc000022090
sasha-deadlock/main.go:19 main.main.func1 { B.Lock() } <<<<<
~/go/pkg/mod/github.com/sasha-s/go-deadlock@v0.3.1/deadlock.go:84 go-deadlock.(*Mutex).Lock { func (m *Mutex) Lock() { }
Here is what goroutine 1 doing now
goroutine 1 [sleep]:
time.Sleep(0x2540be400)
/home/llorllale/.gvm/gos/go1.19/src/runtime/time.go:195 +0x135
main.main()
/home/llorllale/scratchpad/sasha-deadlock/main.go:28 +0x165
Other goroutines holding locks:
goroutine 1 lock 0xc000022078
sasha-deadlock/main.go:14 main.main { A.Lock() } <<<<<
~/go/pkg/mod/github.com/sasha-s/go-deadlock@v0.3.1/deadlock.go:84 go-deadlock.(*Mutex).Lock { func (m *Mutex) Lock() { }
~/.gvm/gos/go1.19/src/runtime/proc.go:258 runtime.main { // Once it does, it will exit. See issues 3934 and 20018. }
POTENTIAL DEADLOCK:
Previous place where the lock was grabbed
goroutine 1 lock 0xc000022090
sasha-deadlock/main.go:16 main.main { } <<<<<
~/go/pkg/mod/github.com/sasha-s/go-deadlock@v0.3.1/deadlock.go:84 go-deadlock.(*Mutex).Lock { func (m *Mutex) Lock() { }
~/.gvm/gos/go1.19/src/runtime/proc.go:258 runtime.main { // Once it does, it will exit. See issues 3934 and 20018. }
Have been trying to lock it again for more than 1s
goroutine 8 lock 0xc000022090
sasha-deadlock/main.go:19 main.main.func1 { B.Lock() } <<<<<
~/go/pkg/mod/github.com/sasha-s/go-deadlock@v0.3.1/deadlock.go:84 go-deadlock.(*Mutex).Lock { func (m *Mutex) Lock() { }
Here is what goroutine 1 doing now
goroutine 1 [sleep]:
time.Sleep(0x2540be400)
/home/llorllale/.gvm/gos/go1.19/src/runtime/time.go:195 +0x135
main.main()
/home/llorllale/scratchpad/sasha-deadlock/main.go:28 +0x165
Other goroutines holding locks:
goroutine 1 lock 0xc000022078
sasha-deadlock/main.go:14 main.main { A.Lock() } <<<<<
~/go/pkg/mod/github.com/sasha-s/go-deadlock@v0.3.1/deadlock.go:84 go-deadlock.(*Mutex).Lock { func (m *Mutex) Lock() { }
~/.gvm/gos/go1.19/src/runtime/proc.go:258 runtime.main { // Once it does, it will exit. See issues 3934 and 20018. }
POTENTIAL DEADLOCK:
Previous place where the lock was grabbed
goroutine 1 lock 0xc000022090
sasha-deadlock/main.go:16 main.main { } <<<<<
~/go/pkg/mod/github.com/sasha-s/go-deadlock@v0.3.1/deadlock.go:84 go-deadlock.(*Mutex).Lock { func (m *Mutex) Lock() { }
~/.gvm/gos/go1.19/src/runtime/proc.go:258 runtime.main { // Once it does, it will exit. See issues 3934 and 20018. }
Have been trying to lock it again for more than 1s
goroutine 8 lock 0xc000022090
sasha-deadlock/main.go:19 main.main.func1 { B.Lock() } <<<<<
~/go/pkg/mod/github.com/sasha-s/go-deadlock@v0.3.1/deadlock.go:84 go-deadlock.(*Mutex).Lock { func (m *Mutex) Lock() { }
Here is what goroutine 1 doing now
goroutine 1 [sleep]:
time.Sleep(0x2540be400)
/home/llorllale/.gvm/gos/go1.19/src/runtime/time.go:195 +0x135
main.main()
/home/llorllale/scratchpad/sasha-deadlock/main.go:28 +0x165
Other goroutines holding locks:
goroutine 1 lock 0xc000022078
sasha-deadlock/main.go:14 main.main { A.Lock() } <<<<<
~/go/pkg/mod/github.com/sasha-s/go-deadlock@v0.3.1/deadlock.go:84 go-deadlock.(*Mutex).Lock { func (m *Mutex) Lock() { }
~/.gvm/gos/go1.19/src/runtime/proc.go:258 runtime.main { // Once it does, it will exit. See issues 3934 and 20018. }
POTENTIAL DEADLOCK:
Previous place where the lock was grabbed
goroutine 1 lock 0xc000022090
sasha-deadlock/main.go:16 main.main { } <<<<<
~/go/pkg/mod/github.com/sasha-s/go-deadlock@v0.3.1/deadlock.go:84 go-deadlock.(*Mutex).Lock { func (m *Mutex) Lock() { }
~/.gvm/gos/go1.19/src/runtime/proc.go:258 runtime.main { // Once it does, it will exit. See issues 3934 and 20018. }
Have been trying to lock it again for more than 1s
goroutine 8 lock 0xc000022090
sasha-deadlock/main.go:19 main.main.func1 { B.Lock() } <<<<<
~/go/pkg/mod/github.com/sasha-s/go-deadlock@v0.3.1/deadlock.go:84 go-deadlock.(*Mutex).Lock { func (m *Mutex) Lock() { }
Here is what goroutine 1 doing now
goroutine 1 [sleep]:
time.Sleep(0x2540be400)
/home/llorllale/.gvm/gos/go1.19/src/runtime/time.go:195 +0x135
main.main()
/home/llorllale/scratchpad/sasha-deadlock/main.go:28 +0x165
Other goroutines holding locks:
goroutine 1 lock 0xc000022078
sasha-deadlock/main.go:14 main.main { A.Lock() } <<<<<
~/go/pkg/mod/github.com/sasha-s/go-deadlock@v0.3.1/deadlock.go:84 go-deadlock.(*Mutex).Lock { func (m *Mutex) Lock() { }
~/.gvm/gos/go1.19/src/runtime/proc.go:258 runtime.main { // Once it does, it will exit. See issues 3934 and 20018. }