Closed
Description
Reproduce Procedure
The panic is as follows:
(ENV) πΊ /Users/go/src/github.com/etcd-io/etcd β git:(test) β ./bin/etcd version
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x135b7ce]
goroutine 1 [running]:
go.uber.org/zap.(*Logger).check(0x0, 0x1, 0x1c5d90a, 0x16, 0xc000091800)
/Users/go/src/github.com/etcd-io/etcd/vendor/go.uber.org/zap/logger.go:263 +0x90e
go.uber.org/zap.(*Logger).Warn(0x0, 0x1c5d90a, 0x16, 0xc000091800, 0x1, 0x1)
/Users/go/src/github.com/etcd-io/etcd/vendor/go.uber.org/zap/logger.go:194 +0x44
go.etcd.io/etcd/v3/etcdmain.startEtcdOrProxyV2()
/Users/go/src/github.com/etcd-io/etcd/etcdmain/etcd.go:61 +0x327
go.etcd.io/etcd/v3/etcdmain.Main()
/Users/go/src/github.com/etcd-io/etcd/etcdmain/main.go:46 +0x37
main.main()
/Users/go/src/github.com/etcd-io/etcd/main.go:28 +0x20
What are we using?
(ENV) β /Users/go/src/github.com/etcd-io/etcd β git:(test) β ./bin/etcd --version
etcd Version: 3.5.0-pre
Git SHA: 9b6c3e337
Go Version: go1.14.3
Go OS/Arch: darwin/amd64
Analysis
The root cause is lg
will be nil in line 61 if config parsing returns a error in the file of etcdmain/etcd.go
, because lg
will be initialized during the configFromCmdLine()
.
52 func startEtcdOrProxyV2() {
53 grpc.EnableTracing = false
54
55 cfg := newConfig()
56 defaultInitialCluster := cfg.ec.InitialCluster
57
58 err := cfg.parse(os.Args[1:])
59 lg := cfg.ec.GetLogger()
60 if err != nil {
61 lg.Warn("failed to verify flags", zap.Error(err))
62 switch err {
63 case embed.ErrUnsetAdvertiseClientURLsFlag:
64 lg.Warn("advertise client URLs are not set", zap.Error(err))
65 }
66 os.Exit(1)
67 }
Activity
microyahoo commentedon Jun 15, 2020
I have noticed this issue was introduced with PR 0a05f1a. Will the package
github.com/coreos/pkg/capnslog
be removed permanently? @jingyihspzala commentedon Jun 15, 2020
@microyahoo yes, and the issue is now fixed under #11962
spzala commentedon Jun 15, 2020
I am closing it @microyahoo Thanks!