From 2eeec737704a2535f06f1527e9bf52b45fe73c0e Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 1 Nov 2021 12:19:00 +0300 Subject: [PATCH] network: don't panic if there is no reason for disconnect Although error should always be there, we shouldn't fail like this if it's not: | panic: runtime error: invalid memory address or nil pointer dereference | [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xc8884c] | | goroutine 113 [running]: | github.com/nspcc-dev/neo-go/pkg/network.(*Server).run(0xc000150580) | github.com/nspcc-dev/neo-go/pkg/network/server.go:396 +0x7ac | github.com/nspcc-dev/neo-go/pkg/network.(*Server).Start(0xc000150580, 0x0) | github.com/nspcc-dev/neo-go/pkg/network/server.go:294 +0x3fb | created by github.com/nspcc-dev/neo-go/cli/server.startServer | github.com/nspcc-dev/neo-go/cli/server/server.go:344 +0x56f --- pkg/network/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/network/server.go b/pkg/network/server.go index c702a66ac..3eb6e06f7 100644 --- a/pkg/network/server.go +++ b/pkg/network/server.go @@ -393,7 +393,7 @@ func (s *Server) run() { s.lock.Unlock() s.log.Warn("peer disconnected", zap.Stringer("addr", drop.peer.RemoteAddr()), - zap.String("reason", drop.reason.Error()), + zap.Error(drop.reason), zap.Int("peerCount", s.PeerCount())) addr := drop.peer.PeerAddr().String() if drop.reason == errIdenticalID {