solo-io / go-utils

golang utilities
Apache License 2.0
110 stars 18 forks source link

runtime error: invalid memory address or nil pointer dereference #475

Closed day0ops closed 1 year ago

day0ops commented 2 years ago

Issue When http://localhost:9091/logging endpoint is called (or on PUT) it throws the following stack trace,

2022/01/11 11:15:53 http: panic serving 127.0.0.1:36464: runtime error: invalid memory address or nil pointer dereference
goroutine 29495 [running]:
net/http.(*conn).serve.func1(0xc0012f2460)
    /usr/local/go/src/net/http/server.go:1824 +0x14c
panic(0x39da340, 0x59c6d20)
    /usr/local/go/src/runtime/panic.go:971 +0x4c7
go.uber.org/atomic.(*Int32).Store(0x0, 0xc0ffffffff)
    /go/pkg/mod/go.uber.org/atomic@v1.7.0/int32.go:75 +0x5
go.uber.org/zap.AtomicLevel.SetLevel(0x0, 0xc002398fff)
    /go/pkg/mod/go.uber.org/zap@v1.16.0/level.go:102 +0x35
go.uber.org/zap.AtomicLevel.ServeHTTP(0x0, 0x42b6e20, 0xc0019f4fc0, 0xc000adf000)
    /go/pkg/mod/go.uber.org/zap@v1.16.0/http_handler.go:72 +0x30a
net/http.(*ServeMux).ServeHTTP(0xc0008d1680, 0x42b6e20, 0xc0019f4fc0, 0xc000adf000)
    /usr/local/go/src/net/http/server.go:2448 +0x1ab
net/http.serverHandler.ServeHTTP(0xc0006f6000, 0x42b6e20, 0xc0019f4fc0, 0xc000adf000)
    /usr/local/go/src/net/http/server.go:2887 +0x22b
net/http.(*conn).serve(0xc0012f2460, 0x42bcc50, 0xc0020d4fc0)
    /usr/local/go/src/net/http/server.go:1952 +0x1c25
created by net/http.(*Server).Serve
    /usr/local/go/src/net/http/server.go:3013 +0x96e

This doesnt seem to me impacting any of the following endpoints,

This appears to be affecting all GE versions 1.9.0+.

Potential fix Investigating this further it appears to be because of logLevel being nil in stats.go. It isnt being set in either of the cases,