From f961c571bdf9971a4ac29f5effd294a12adbd450 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 13 Feb 2019 16:33:34 +0300 Subject: [PATCH] registry: [gossip] fix panic panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x88 pc=0xd1b215] goroutine 8 [running]: sync.(*RWMutex).RLock(...) /var/home/vtolstov/sdk/go1.12beta2/src/sync/rwmutex.go:48 github.com/hashicorp/memberlist.(*Memberlist).LocalNode(0x0, 0x0) /home/vtolstov/devel/projects/centralv2/vendor/github.com/hashicorp/memberlist/memberlist.go:417 +0x35 github.com/micro/go-micro/registry/gossip.(*gossipRegistry).run.func3(0xc000155880) /home/vtolstov/devel/projects/centralv2/vendor/github.com/micro/go-micro/registry/gossip/gossip.go:565 +0xf5 created by github.com/micro/go-micro/registry/gossip.(*gossipRegistry).run /home/vtolstov/devel/projects/centralv2/vendor/github.com/micro/go-micro/registry/gossip/gossip.go:553 +0xa25 Signed-off-by: Vasiliy Tolstov --- registry/gossip/gossip.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/registry/gossip/gossip.go b/registry/gossip/gossip.go index 027d42e1..a5e4f5a3 100644 --- a/registry/gossip/gossip.go +++ b/registry/gossip/gossip.go @@ -561,9 +561,11 @@ func (g *gossipRegistry) run() { case <-ticker.C: var addrs []string g.RLock() - for node, action := range g.members { - if action == nodeActionLeave && g.member.LocalNode().Address() != node { - addrs = append(addrs, node) + if g.member != nil { + for node, action := range g.members { + if action == nodeActionLeave && g.member.LocalNode().Address() != node { + addrs = append(addrs, node) + } } } g.RUnlock()