go-zeromq / zmq4

[WIP] Pure-Go implementation of ZeroMQ-4
BSD 3-Clause "New" or "Revised" License
344 stars 57 forks source link

Dead lock, how to fix? #132

Open hailwind opened 2 years ago

hailwind commented 2 years ago

goroutine stack behind, how to fix this problem?

1 @ 0x43a576 0x44aff3 0x44afcd 0x4661e5 0x481732 0x74fa67 0x7763d7 0x774a46 0x78c84d 0x78cd87 0x78cf78 0x46a141
#   0x4661e4    sync.runtime_Semacquire+0x24                /opt/go/src/runtime/sema.go:56
#   0x481731    sync.(*WaitGroup).Wait+0x51             /opt/go/src/sync/waitgroup.go:136
#   0x74fa66    golang.org/x/sync/errgroup.(*Group).Wait+0x26       /home/alexw/go/pkg/mod/golang.org/x/sync@v0.0.0-20220601150217-0de741cfad7f/errgroup/errgroup.go:53
#   0x7763d6    github.com/go-zeromq/zmq4.(*routerMWriter).write+0x2d6  /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/router.go:242
#   0x774a45    github.com/go-zeromq/zmq4.(*routerSocket).Send+0xe5 /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/router.go:40
#   0x78c84c    sdwan/ctrl/device.(*ZeroMQ).sendMsg+0x28c       /home/alexw/workspace/hw-agent/ctrl/device/zmq.go:60
#   0x78cd86    sdwan/ctrl/device.(*ZeroMQ).runSend+0x126       /home/alexw/workspace/hw-agent/ctrl/device/zmq.go:102
#   0x78cf77    sdwan/ctrl/device.RunZmq+0xf7               /home/alexw/workspace/hw-agent/ctrl/device/zmq.go:124

1 @ 0x43a576 0x44aff3 0x44afcd 0x466305 0x47fca5 0x47fadb 0x778a99 0x771a02 0x7719ee 0x771b39 0x77117c 0x76fb2d 0x7764ba 0x74fc04 0x46a141
#   0x466304    sync.runtime_SemacquireMutex+0x24               /opt/go/src/runtime/sema.go:71
#   0x47fca4    sync.(*Mutex).lockSlow+0x164                    /opt/go/src/sync/mutex.go:162
#   0x47fada    sync.(*Mutex).Lock+0x3a                     /opt/go/src/sync/mutex.go:81
#   0x778a98    github.com/go-zeromq/zmq4.(*socket).scheduleRmConn+0x38     /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/socket.go:334
#   0x771a01    github.com/go-zeromq/zmq4.(*Conn).notifyOnCloseError+0x41   /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/conn.go:500
#   0x7719ed    github.com/go-zeromq/zmq4.(*Conn).SetClosed+0x2d        /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/conn.go:472
#   0x771b38    github.com/go-zeromq/zmq4.(*Conn).checkIO+0xf8          /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/conn.go:492
#   0x77117b    github.com/go-zeromq/zmq4.(*Conn).send+0x17b            /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/conn.go:357
#   0x76fb2c    github.com/go-zeromq/zmq4.(*Conn).SendMsg+0x16c         /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/conn.go:190
#   0x7764b9    github.com/go-zeromq/zmq4.(*routerMWriter).write.func1+0x39 /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/router.go:239
#   0x74fc03    golang.org/x/sync/errgroup.(*Group).Go.func1+0x63       /home/alexw/go/pkg/mod/golang.org/x/sync@v0.0.0-20220601150217-0de741cfad7f/errgroup/errgroup.go:75

1 @ 0x43a576 0x44aff3 0x44afcd 0x466305 0x47fca5 0x47fadb 0x778a99 0x771a02 0x7719ee 0x771b39 0x77188f 0x7758c8 0x46a141
#   0x466304    sync.runtime_SemacquireMutex+0x24               /opt/go/src/runtime/sema.go:71
#   0x47fca4    sync.(*Mutex).lockSlow+0x164                    /opt/go/src/sync/mutex.go:162
#   0x47fada    sync.(*Mutex).Lock+0x3a                     /opt/go/src/sync/mutex.go:81
#   0x778a98    github.com/go-zeromq/zmq4.(*socket).scheduleRmConn+0x38     /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/socket.go:334
#   0x771a01    github.com/go-zeromq/zmq4.(*Conn).notifyOnCloseError+0x41   /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/conn.go:500
#   0x7719ed    github.com/go-zeromq/zmq4.(*Conn).SetClosed+0x2d        /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/conn.go:472
#   0x771b38    github.com/go-zeromq/zmq4.(*Conn).checkIO+0xf8          /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/conn.go:492
#   0x77188e    github.com/go-zeromq/zmq4.(*Conn).read+0x68e            /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/conn.go:385
#   0x7758c7    github.com/go-zeromq/zmq4.(*routerQReader).listen+0x1a7     /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/router.go:161

1 @ 0x43a576 0x44aff3 0x44afcd 0x466305 0x47fca5 0x481296 0x481275 0x7782c5 0x777c5c 0x46a141
#   0x466304    sync.runtime_SemacquireMutex+0x24           /opt/go/src/runtime/sema.go:71
#   0x47fca4    sync.(*Mutex).lockSlow+0x164                /opt/go/src/sync/mutex.go:162
#   0x481295    sync.(*Mutex).Lock+0x35                 /opt/go/src/sync/mutex.go:81
#   0x481274    sync.(*RWMutex).Lock+0x14               /opt/go/src/sync/rwmutex.go:139
#   0x7782c4    github.com/go-zeromq/zmq4.(*socket).addConn+0x64    /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/socket.go:285
#   0x777c5b    github.com/go-zeromq/zmq4.(*socket).accept+0x1fb    /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/socket.go:227

1 @ 0x43a576 0x44aff3 0x44afcd 0x466305 0x47fca5 0x775ea5 0x775e75 0x77897c 0x778f1d 0x46a141
#   0x466304    sync.runtime_SemacquireMutex+0x24           /opt/go/src/runtime/sema.go:71
#   0x47fca4    sync.(*Mutex).lockSlow+0x164                /opt/go/src/sync/mutex.go:162
#   0x775ea4    sync.(*Mutex).Lock+0x64                 /opt/go/src/sync/mutex.go:81
#   0x775e74    github.com/go-zeromq/zmq4.(*routerMWriter).rmConn+0x34  /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/router.go:211
#   0x77897b    github.com/go-zeromq/zmq4.(*socket).rmConn+0x23b    /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/socket.go:329
#   0x778f1c    github.com/go-zeromq/zmq4.(*socket).connReaper+0x17c    /home/alexw/go/pkg/mod/github.com/go-zeromq/zmq4@v0.15.0/socket.go:393
tgbv commented 2 years ago

some code sample would be useful in diagnosing it

egorse commented 6 months ago

Fixed by #149 ?